Skip to content

Commit

Permalink
fix: allow lock focus for specific list (#1340)
Browse files Browse the repository at this point in the history
* fix: allow lock focus for specific list in dialog

* fix: fix lint

* fix: optimize naming and description
  • Loading branch information
Vita-Meow authored Jul 21, 2021
1 parent 0950399 commit 2b73876
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Dialog extends Component {
subheader,
titleProps,
title,
allowListForLockFocus,
...rest
} = this.props;

Expand Down Expand Up @@ -103,7 +104,8 @@ class Dialog extends Component {

return ReactDOM.createPortal(
<FocusLock as='div' className={backdropClassName}
lockProps={{ ...rest }}>
lockProps={{ ...rest }}
whiteList={allowListForLockFocus}>
<span data-autofocus tabIndex='-1' />
<div
aria-label={title}
Expand Down Expand Up @@ -165,6 +167,8 @@ Dialog.propTypes = {
actions: PropTypes.arrayOf(PropTypes.node).isRequired,
/** Localized text for the heading */
title: PropTypes.string.isRequired,
/** Specific list of node to lock the focus*/
allowListForLockFocus: PropTypes.node,
/** CSS class(es) to add to the dialog backdrop */
backdropClassName: PropTypes.string,
/** Additional props to be spread to the body section of the dialog */
Expand Down

0 comments on commit 2b73876

Please sign in to comment.