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.
|
{-| Pass the id of the element that should receive focus when the modal is closed.
|
||||||
-}
|
-}
|
||||||
initOpen : String -> Model
|
initOpen : String -> ( Model, Cmd Msg )
|
||||||
initOpen =
|
initOpen returnFocusTo =
|
||||||
Opened
|
( 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 =
|
update { dismissOnEscAndOverlayClick } msg model =
|
||||||
case msg of
|
case msg of
|
||||||
OpenModal returnFocusTo ->
|
OpenModal returnFocusTo ->
|
||||||
( Opened returnFocusTo
|
( Opened returnFocusTo, focusFirstElement )
|
||||||
, Dom.focus autofocusId
|
|
||||||
|> Task.onError (\_ -> Dom.focus firstId)
|
|
||||||
|> Task.attempt Focused
|
|
||||||
)
|
|
||||||
|
|
||||||
CloseModal by ->
|
CloseModal by ->
|
||||||
let
|
let
|
||||||
|
Loading…
Reference in New Issue
Block a user