Closed MethodGrab closed 6 years ago
Here is a reduced SSCCE:
module Main exposing (main)
import Browser
import Html as H exposing (Html)
import Html.Attributes as HA
import Time exposing (Posix)
main : Program () Model Msg
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
type alias Model = ()
type Msg = Tick
init : a -> ( Model, Cmd msg )
init flags =
( (), Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions model =
Time.every 1000 (always Tick)
update : Msg -> Model -> ( Model, Cmd msg )
update msg model =
( (), Cmd.none )
optionView selected option =
H.option
[ HA.selected (option == selected)
, HA.value option -- remove this line to fix
]
[ H.text option ]
view : Model -> Html Msg
view model =
H.select []
([ "1", "2", "3", "4", "5" ]
|> List.map (optionView "4")
)
Note: removing the line I marked -- remove this line to fix
prevents the selected option reverting.
Elm: 0.19 Browser: Firefox v61.0.2 x64 (Windows 10 & Ubuntu 16.04)
Elm 0.19 seems to have a problem with select inputs in Firefox. I have a tick subscription that updates the current time every second. When I try to select a value from an
Html.select
element in Firefox, as soon as the tick fires, it resets the selected value back to the value specified byHtml.Attributes.selected
instead of leaving it where my cursor is.I'm not sure if this issue is related to elm/html or elm/virtual-dom.
To reproduce:
https://ellie-app.com/3cysgr6wX2Sa1https://ellie-app.com/3cFs4FWXhQxa1 in Firefox4
)SSCCE