NoRedInk/noredink-ui/18.5.1

NOTE: the latest version is 35.9.3

Nri.Ui.WhenFocusLeaves.V1

TODO in next major version: remove toAttribute.

Listen for when the focus leaves the area, and then do an action.

{ firstId : String
, lastId : String
, tabBackAction : msg
, tabForwardAction : msg
}
-> Attribute msg

DEPRECATED: Use toDecoder instead

Attach this attribute to add a focus watcher to an HTML element and define what to do in reponse to tab keypresses in a part of the UI.

The ids referenced here are expected to correspond to elements in the container we are adding the attribute to.

{ firstId : String
, lastId : String
, tabBackAction : msg
, tabForwardAction : msg
}
-> Decoder msg

Use this decoder to add a focus watcher to an HTML element and define what to do in reponse to tab keypresses in a part of the UI.

The ids referenced here are expected to correspond to elements in the container we are adding the attribute to.

NOTE: When needing to listen to multiple keys toDecoder should be used instead of toAttribute.

import Accessibility.Styled.Key as Key


Key.onKeyDown
    [ Key.escape CloseModal
    , toDecoder config
    ]