1

Anyone know if there's a way to programmatically set focus on an Element.Input.text element using stylish-elephants (or style-element v5)?

Jason O.
  • 3,168
  • 6
  • 33
  • 72

1 Answers1

3

It requires "elm-lang/dom": "1.1.1 <= v < 2.0.0" in elm-package.json

import Dom exposing (focus)

update msg model =
  case msg of
    FocusOn id ->
        { model | current_focus_id = id } ! [ Task.attempt FocusResult (focus (id)) ]

    FocusResult result ->
        case result of
            Err (Dom.NotFound id) ->
                model ! [ YourMsg]

            Ok () ->
                model ! []

view model = Element.layout []  <| el [onClick <| (FocusOn "id01")] (text "click here")
Jason O.
  • 3,168
  • 6
  • 33
  • 72