This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dialog): Handle focus trapping correctly (#491)
- Remove all focus trapping logic within the dialog foundation, replacing it with adapter methods set up to handle focus trapping. - Add [focus-trap](https://npmjs.com/focus-trap) as a dependency and use it for implementing the adapter methods at the component level - Add a util method for easily creating properly configured focus-trap instances that framework components can use when implementing their adapters. - Remove use of aria-hidden and replace with visibility styles so that tab-focusing works correctly when dialog is hidden. - [techdebt] Remove all unnecessary adapter API methods and dead code - [techdebt] Make grammatical corrections in README - [techdebt] Remove unneeded passive event listener logic for dialog handlers - [demos] Fix ripples incorrectly appearing in buttons within the demos. Resolves #424 Resolves #409 Resolves #426 NOTE: The additional issues resolved are by-products from switching to focus-trap. BREAKING CHANGE: There are a few changes that need to be taken into account for this commit: - Dialogs no longer require an `aria-hidden="true"` attribute. - Dialogs _do_ require a `style="visibility:hidden"` attribute for correct first render. - `trapFocusOnSurface` and `untrapFocusOnSurface` methods must be implemented for the adapter - `hasClass`, `setAttr`, `registerFocusTrappingHandler`, `deregisterFocusTrappingHandler`, `numFocusableTargets`, `setDialogFocusFirstTarget`, `setInitialFocus`, `getFocusableElements`, `saveElementTabState`, `restoreElementTabState`, `makeElementUntabbable`, `setBodyAttr`, `rmBodyAttr`, `getFocusedTarget`, and `setFocusedTarget` have all been removed from the adapter. - `applyPassive`, `saveElementTabState`, and `restoreElementTabState` have all been removed from `mdcDialog.util`.
- Loading branch information
1 parent
ff772ad
commit 12bd03e
Showing
11 changed files
with
205 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.