mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-28 10:17:49 +03:00
initOpen autofocuses on the first element
This commit is contained in:
parent
9a67a64d63
commit
0768862b8b
@ -79,9 +79,16 @@ init =
|
||||
|
||||
{-| Pass the id of the element that should receive focus when the modal is closed.
|
||||
-}
|
||||
initOpen : String -> Model
|
||||
initOpen =
|
||||
Opened
|
||||
initOpen : String -> ( Model, Cmd Msg )
|
||||
initOpen returnFocusTo =
|
||||
( Opened returnFocusTo, focusFirstElement )
|
||||
|
||||
|
||||
focusFirstElement : Cmd Msg
|
||||
focusFirstElement =
|
||||
Dom.focus autofocusId
|
||||
|> Task.onError (\_ -> Dom.focus firstId)
|
||||
|> Task.attempt Focused
|
||||
|
||||
|
||||
{-| -}
|
||||
@ -126,11 +133,7 @@ update : { dismissOnEscAndOverlayClick : Bool } -> Msg -> Model -> ( Model, Cmd
|
||||
update { dismissOnEscAndOverlayClick } msg model =
|
||||
case msg of
|
||||
OpenModal returnFocusTo ->
|
||||
( Opened returnFocusTo
|
||||
, Dom.focus autofocusId
|
||||
|> Task.onError (\_ -> Dom.focus firstId)
|
||||
|> Task.attempt Focused
|
||||
)
|
||||
( Opened returnFocusTo, focusFirstElement )
|
||||
|
||||
CloseModal by ->
|
||||
let
|
||||
|
Loading…
Reference in New Issue
Block a user