Skip to content

Commit

Permalink
fix(ComposedModal): close modal with esc key when no element has focus (
Browse files Browse the repository at this point in the history
#11609)

* fix(ComposedModal): close modal with esc key when no element has focus

* test(ComposedModal): update snapshots

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Josh Black <[email protected]>
  • Loading branch information
3 people authored Jun 17, 2022
1 parent 76faa44 commit f72a96a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/react/src/components/ComposedModal/ComposedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ export default class ComposedModal extends Component {
onClick={this.handleClick}
onKeyDown={this.handleKeyDown}
onTransitionEnd={open ? this.handleTransitionEnd : undefined}
className={modalClass}>
className={modalClass}
tabIndex="-1">
{/* Non-translatable: Focus-wrap code makes this `<span>` not actually read by screen readers */}
<span
ref={this.startSentinel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`<ComposedModal /> renders 1`] = `
onTransitionEnd={[Function]}
open={true}
role="presentation"
tabIndex="-1"
>
<span
className="cds--visually-hidden"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ const ComposedModal = React.forwardRef(function ComposedModal(
onBlur={handleBlur}
onClick={handleClick}
onKeyDown={handleKeyDown}
className={modalClass}>
className={modalClass}
tabIndex="-1">
<div
className={containerClass}
role="dialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`<ComposedModal /> renders 1`] = `
onClick={[Function]}
onKeyDown={[Function]}
role="presentation"
tabIndex="-1"
>
<div
aria-modal="true"
Expand Down

0 comments on commit f72a96a

Please sign in to comment.