I am working on incorporating the button click with code block into our bank of snippets to create a more interactive user experience. One thing I/we noticed right off the bat with the following snippet example is, when clicking the Add One button to add a new bullet poing and formtext field, the new field is not brought into focus to immediately type into. The user must tab nagivate to it or grab their mouse to click on it. This is a slow down. Am I missing something in the coding?
**Task list:**
{repeat: for index in seq(1, item_count)}{formtext}{if: index < item_count}
{endif}{endrepeat} {note: insert=no; preview=yes}{note: preview=no}{run: item_count = 1
}{endnote}{button: item_count = item_count + 1
; label=Add One} {button: item_count = item_count - 1
; label=Remove Last; disabled={=item_count = 1}}{endnote}
It seems like that does not work for you. We can extend the focus() function so that it takes an index allowing it to focus the index-th instance of the field. For example, above we could use: focus("name", item_count) to focus the item_count-th instance. Would that work for you? Or any other suggestions you like to add here?
Thank you for the idea! I see what you mean. I tested what you provided, but it only keeps focus on the first item regardless of how many are added/removed.
As for my having any other suggestions, maybe there is something like this that could work. When a new item is added, its name is changed sequentially:
item1
item2
item3
etc.
etc
Then, the focus function is applied to whichever is most recently added or removed (removed -1 actually because I think that would be needed in order to focus on the last visible item).
I'm not sure if this meets the UI you're looking for, but you could also have it display a new field every time the field is used. So basically, there is always another field to complete. That'd be faster for power users tabbing through, but I still agree the issue you brought up here should be sorted.
Task list:
{note: preview=no}{filled=count(filter(names, x -> x.name <> ""))}{endnote}{repeat: for i in seq(1, 1 + filled); locals=names}{formtext: name=name}
{endrepeat}