handleKey: List String -> Int -> Action
handleKey options code =
case code of
13 -> Submit (List.head options)
27 -> Close
_ -> NoOp
openDropdown : Signal.Address Action -> Model -> List String -> Html
openDropdown address model options =
div [ attribute "aria-label" "Filter venue"
, class "ui search selection dropdown active visible"
, onWithOptions "keydown" evOptions keyCode (\code -> Signal.message address (handleKey options code))
]
[ i [ class "dropdown icon" ] []
, input
[ on "input" targetValue (Signal.message address << Update)
, placeholder model.value
, tabindex 0] []
, div [ class "text" ] [ text model.inputValue ]
, div [ class "menu transition visible", attribute "style" "display: block !important;", tabindex -1 ]
(itemsView address model.value filtered)
]