With the following code, when input text reaches 5 characters, the input field will lose focus.
If I change else
branch to [ H.text "" ]
then focus is not lost.
Is there a way to keep focus without requiring then
and else
branches to generate exact same number of Html elements?
Full example: https://ellie-app.com/8Gz95rL2Kx4a1
view : Model -> Html Msg
view model =
let
notice =
if String.length model.text == 5 then
[ H.text "Length is 5" ]
else
[]
in
H.div []
(notice
++ [ H.br [] []
, H.input
[ A.type_ "text"
, A.value model.text
, E.onInput TextChanged
]
[]
]
)