Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
[terra-modal manager] Implemented focus lock to confine focus within …
Browse files Browse the repository at this point in the history
…the modal popup. (#2014)

Co-authored-by: AH106586Harika <[email protected]>
Co-authored-by: MadanKumarGovindaswamy <[email protected]>
  • Loading branch information
3 people authored Feb 15, 2024
1 parent 5d99ec2 commit 2b3357e
Show file tree
Hide file tree
Showing 23 changed files with 2,518 additions and 280 deletions.
208 changes: 205 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/terra-abstract-modal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Added
* Added FocusOn to confine focus within the modal popup.

## 3.45.0 - (December 18, 2023)

* Changed
Expand Down
1 change: 1 addition & 0 deletions packages/terra-abstract-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"keycode-js": "^3.1.0",
"mutationobserver-shim": "<=0.3.3",
"prop-types": "^15.5.8",
"react-focus-on": "^3.9.1",
"react-portal": "^4.1.2",
"terra-theme-context": "^1.9.0",
"terra-visually-hidden-text": "^2.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/terra-abstract-modal/src/AbstractModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const propTypes = {
* If set to true, the AbstractModal is rendered inside a NotificationDialog.
*/
isCalledFromNotificationDialog: PropTypes.bool,
/**
* If set to true, then the focus lock will get enabled.
*/
shouldTrapFocus: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -90,6 +94,7 @@ const defaultProps = {
rootSelector: '#root',
zIndex: '6000',
isCalledFromNotificationDialog: false,
shouldTrapFocus: false,
};

const AbstractModal = (props) => {
Expand All @@ -109,6 +114,7 @@ const AbstractModal = (props) => {
onRequestClose,
zIndex,
isCalledFromNotificationDialog,
shouldTrapFocus,
...customProps
} = props;

Expand Down Expand Up @@ -174,6 +180,7 @@ const AbstractModal = (props) => {
ref={modalElementRef}
onKeyDown={handleKeydown}
isCalledFromNotificationDialog={isCalledFromNotificationDialog}
shouldTrapFocus={shouldTrapFocus}
>
{children}
</ModalContent>
Expand Down
Loading

0 comments on commit 2b3357e

Please sign in to comment.