From 3b5ef488d4ed676134d65c4118097dd290cc9013 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 10 Jan 2020 09:51:04 +0100 Subject: UList.VoteEdit: Fix enter key when setting custom vote in Chrome-based browsers By using a form.onsubmit rather than input.onkeydown. The latter behaves really strange in Chrome for some reason I wasn't able to figure out. (The Elm 'Save' message was fired twice, but the corresponding Cmd returned by the update function was never actually performed) --- elm/UList/VoteEdit.elm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/elm/UList/VoteEdit.elm b/elm/UList/VoteEdit.elm index f34b133c..aa5d6027 100644 --- a/elm/UList/VoteEdit.elm +++ b/elm/UList/VoteEdit.elm @@ -3,7 +3,6 @@ port module UList.VoteEdit exposing (main, init, update, view, Model, Msg) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) -import Json.Decode as JD import Browser import Task import Lib.Html exposing (..) @@ -93,7 +92,7 @@ view model = in li [] [ linkRadio (Just sn == model.ovote) (Set (Just sn)) [ text <| sn ++ " (" ++ s ++ ")" ] ] ) (List.reverse ratings) ++ - [ li [] [ p [] + [ li [] [ Html.form [ onSubmit Save ] [ p [] [ text "custom: " , input ( [ type_ "text" @@ -105,13 +104,9 @@ view model = , onFocus Focus , placeholder "7.5" , style "width" "55px" - , custom "keydown" -- Grab enter key - <| JD.andThen (\c -> if c == "Enter" then JD.succeed { preventDefault = True, stopPropagation = True, message = Save } else JD.fail "") - <| JD.field "key" JD.string - ] - ++ GVE.valVote + ] ++ GVE.valVote ) [] - ] + ] ] ] ] ++ ( if isJust (model.ovote) -- cgit v1.2.3