From 9b76457fb5e85d43a5c2ffd3d18e2ebf663b38f9 Mon Sep 17 00:00:00 2001 From: Tessa Kelly Date: Wed, 2 Sep 2020 10:29:53 -0700 Subject: [PATCH] Change close to return a Model Cmd tuple --- src/Nri/Ui/Modal/V11.elm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Nri/Ui/Modal/V11.elm b/src/Nri/Ui/Modal/V11.elm index 63d530e1..4b6679a7 100644 --- a/src/Nri/Ui/Modal/V11.elm +++ b/src/Nri/Ui/Modal/V11.elm @@ -109,13 +109,8 @@ type By {-| -} -close : Msg -close = - CloseModal Other - - -close_ : Model -> ( Model, Cmd Msg ) -close_ model = +close : Model -> ( Model, Cmd Msg ) +close model = case model of Opened returnFocusTo -> ( Closed, Task.attempt Focused (Dom.focus returnFocusTo) ) @@ -154,11 +149,11 @@ update { dismissOnEscAndOverlayClick } msg model = CloseModal by -> case by of Other -> - close_ model + close model _ -> if dismissOnEscAndOverlayClick then - close_ model + close model else ( model, Cmd.none ) @@ -611,7 +606,7 @@ closeButton : (Msg -> msg) -> List (Html.Attribute msg) -> Html msg closeButton wrapMsg focusableElementAttrs = button (Widget.label "Close modal" - :: Attrs.map wrapMsg (onClick close) + :: Attrs.map wrapMsg (onClick (CloseModal Other)) :: Attrs.css [ -- in the upper-right corner of the modal Css.position Css.absolute