I’d like to return the focus for text input back to a text-input widget after some other activities. Currently, the user types their text, clicks/tabs away, the action is triggered, the text-input is cleared, but the user has to click on the text-input widget again before entering more text.
How can I direct the input-focus back to the widget?
The setTimeout and hacky stuff for pageload is because Firefox does not behave properly with autofocus attribute. If you prefer to just target Chrome, you can call “entry.focus()” directly instead of in a Timeout, and you can remove all the init code after the Firefox comment.
I’m sure there’s a way to do this with a TextInput widget by wrapping it into a ReactiveHTML template then traversing down the child nodes within the JS callbacks. I didn’t need the extra widget features for this however so I went the simpler route.