You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow Modal to place focus on first element within contents via new API (#54590)
* Add new firstContentElement variation to Modal
* Update Story
* Update e2e test
* Add focus tests
* Conditionally add ref
* Provide comment to explain unusual code
* Remove extra div element
* Update docs
* Tweak code comment documentation
* Add test for firstElement
* Refactor tests
* Prefer getByRole
* Improve README with additional context
Copy file name to clipboardExpand all lines: packages/components/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@
11
11
12
12
### Enhancements
13
13
14
+
- Add new option `firstContentElement` to Modal's `focusOnMount` prop to allow consumers to focus the first element within the Modal's **contents** ([#54590](https://github.com/WordPress/gutenberg/pull/54590)).
14
15
-`Notice`: Improve accessibility by adding visually hidden text to clarify what a notice text is about and the notice type (success, error, warning, info) ([#54498](https://github.com/WordPress/gutenberg/pull/54498)).
15
16
- Making Circular Option Picker a `listbox`. Note that while this changes some public API, new props are optional, and currently have default values; this will change in another patch ([#52255](https://github.com/WordPress/gutenberg/pull/52255)).
16
17
-`ToggleGroupControl`: Rewrite backdrop animation using framer motion shared layout animations, add better support for controlled and uncontrolled modes ([#50278](https://github.com/WordPress/gutenberg/pull/50278)).
If this property is true, it will focus the first tabbable element rendered in the modal.
193
193
194
+
If this property is false, focus will not be transferred and it is the responsibility of the consumer to ensure accessible focus management.
195
+
196
+
If set to `firstElement` focus will be placed on the first tabbable element anywhere within the Modal.
197
+
198
+
If set to `firstContentElement` focus will be placed on the first tabbable element within the Modal's **content** (i.e. children). Note that it is the responsibility of the consumer to ensure there is at least one tabbable element within the children **or the focus will be lost**.
0 commit comments