Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Popup): Set aria-modal for both Dialog and Popup with focus trap #995

Merged
merged 4 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `getNextElement`, `getPreviousElement` and `focusAsync` to exported as `FocusZoneUtilities` @layershifter ([#981](https://github.com/stardust-ui/react/pull/981))
- Add `Reaction` and `ReactionGroup` components @mnajdova ([#959](https://github.com/stardust-ui/react/pull/959))
- Add `reactionGroup` and `reactionGroupPosition` props to the `ChatMessage` component @mnajdova ([#959](https://github.com/stardust-ui/react/pull/959))
- Set `aria-modal` attribute for both Dialog and Popup with focus trap @sophieH29 ([#995](https://github.com/stardust-ui/react/pull/995))

### Documentation
- Add `MenuButton` prototype (only available in development mode) @layershifter ([#947](https://github.com/stardust-ui/react/pull/947))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import popupFocusTrapBehavior from '../Popup/popupFocusTrapBehavior'
const dialogBehavior: Accessibility = (props: any) => {
const behaviorData = popupFocusTrapBehavior(props)
behaviorData.attributes.popup = {
...behaviorData.attributes.popup,
role: 'dialog',
'aria-modal': true,
}

return behaviorData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ import popupBehavior from './popupBehavior'
*
* @specification
* Adds attribute 'aria-disabled=true' to 'trigger' component's part if 'disabled' property is true. Does not set the attribute otherwise.
* Adds attribute 'aria-modal=true' to 'popup' component's part.
* Traps focus inside component.
*/
const popupFocusTrapBehavior: Accessibility = (props: any) => ({
...popupBehavior(props),
focusTrap: true,
})
const popupFocusTrapBehavior: Accessibility = (props: any) => {
const behaviorData = popupBehavior(props)
behaviorData.attributes.popup = {
sophieH29 marked this conversation as resolved.
Show resolved Hide resolved
...behaviorData.attributes.popup,
'aria-modal': true,
}
behaviorData.focusTrap = true

return behaviorData
}

export default popupFocusTrapBehavior