How can I set the focus on a Html element in Elm? I tried to set the autofocus attribute on the element and it only sets the focus on the page load.
In Elm 0.19, use Browser.Dom.focus:
import Browser.Dom as Dom import Task type Msg = NoOp focusSearchBox : Cmd Msg focusSearchBox = Task.attempt (\_ -> NoOp) (Dom.focus "search-box")
You can choose to ignore if focusing fails like above or do something by triggering an update message.