fix: update internal usage of useModalAttributes to use legacyTrapFocus by default #31801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The initial decision around whether to use a hard focus trap (i.e. forcing focus back within a modal when it leaves) vs. a soft one (preventing focus from reaching the background page, but allowing it to reach browser controls) was based around where HTML seemed to be going -- both the
dialog
element and theinert
attribute allow you to reach the browser chrome.However, both our v9 Dialog and Popover already use the hard focus trap by default now, and user feedback seems to indicate that's preferred anyway. This PR updates
DatePicker
to be consistent with Dialog & Popover, and updates theuseModalAttributes
hook to also implement a hard focus trap by default. That seems like the best approach for both internal consistency in v9, and for keyboard & screen reader users.