UI/Dialog: Expose initialFocus and finalFocus on Dialog.Popup#76860
UI/Dialog: Expose initialFocus and finalFocus on Dialog.Popup#76860
Conversation
Forward Base UI's `initialFocus` and `finalFocus` props through the `@wordpress/ui` `Dialog.Popup` component. This enables consumers to customize which element receives focus when the dialog opens or closes. These props are picked directly from Base UI's `DialogPopup.Props` type and forwarded to the underlying `<_Dialog.Popup>` element. Made-with: Cursor
|
Size Change: 0 B Total Size: 7.69 MB ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 91fcf9b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23644273374
|
aduth
left a comment
There was a problem hiding this comment.
Seems reasonable, both for feature parity with Modal's existing usage and because it's already handled cleanly by BaseUI 👍
What?
Expose (forward) the Base UI's
initialFocusandfinalFocusprops on the@wordpress/uiDialog.Popupcomponent.Why?
Consumers of
Dialog.Popupneed to customize which element receives focus when the dialog opens or closes. For example, action modals in@wordpress/dataviewsneed to focus the first input in the content area (skipping the header close icon) or focus a specific content element.Without these props, consumers must resort to workarounds like disabling Dialog's focus management entirely and using separate hooks, leading to potential timing conflicts.
How?
Forwarded the props to the underlying Base UI dialog, use original Base UI types.
Testing Instructions
npm run storybook).initialFocus={false}and verify focus does not move on open.Testing Instructions for Keyboard
Use of AI Tools
Cursor + Claude Opus 4.6