summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-01-10 09:51:04 +0100
committerYorhel <git@yorhel.nl>2020-01-10 09:51:06 +0100
commit3b5ef488d4ed676134d65c4118097dd290cc9013 (patch)
treebaeb2fc1144075cd016a8ca0c703ace88e231ed2
parent810f0d61ebcacf768843badc0d73bd66dc52b249 (diff)
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)
-rw-r--r--elm/UList/VoteEdit.elm11
1 files 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)