Editor: Migrate PostActions modal from Modal to @wordpress/ui Dialog#78031
Editor: Migrate PostActions modal from Modal to @wordpress/ui Dialog#78031ciampo wants to merge 3 commits into
PostActions modal from Modal to @wordpress/ui Dialog#78031Conversation
Mirrors the recent dataviews `ActionModal` refactor: the `<Modal>` wrapper becomes `<Dialog.Popup>` (with `Dialog.Header` / `Dialog.Title` / `Dialog.CloseIcon` / `Dialog.Content`), and `Dialog.Root` / `Dialog.Trigger` are hoisted to a per-action `ModalActionMenuItem` so each menu item owns its own open state. Drops the parent-level `activeModalAction` state from `PostActions` and rescopes the legacy z-index to the dialog portal class, matching the dataviews compat sheet. Together with the page-templates migration this hosts every consumer of `action.RenderModal` inside a real `Dialog` ancestor, unblocking the follow-up where each `RenderModal`'s Cancel button can adopt `Dialog.Action`.
Bring the editor's duplicated ActionModal helpers to parity with the canonical dataviews implementation: - Propagate `action.disabled` to the underlying `Menu.Item` (was being silently dropped). - Honour `action.modalSize` (incl. the deprecated `'fill'` value) by duplicating the small `mapModalSize` helper from dataviews. - Honour `action.modalFocusOnMount` by duplicating `useMapFocusOnMount` from dataviews so `'firstInputElement'` actually targets the first input instead of falling back to the popup default. - Document, in a single comment block, that these helpers are duplicated from dataviews and should eventually move to a shared module. Also reframes the `modalHeader`-as-function support and the `hideModalHeader` alert semantics as the bug fixes they really are in the changelog (both behaviours used to silently mismatch dataviews).
|
Size Change: +47.8 kB (+0.6%) Total Size: 8 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
There was a problem hiding this comment.
Pull request overview
This PR migrates the editor’s PostActions (post “More” menu) modal implementation from @wordpress/components Modal to the @wordpress/ui Dialog primitive, aiming to align behavior with the newer dialog system (animation, dismissal, focus, sizing) and remove parent-owned “active action” state.
Changes:
- Replaces the
Modal-basedActionModalwith aDialog.Root/Dialog.Popupimplementation and composesDialog.TriggerwithMenu.Item. - Adds
modalSizemapping (including a deprecation path for'fill') andmodalFocusOnMountmapping toDialog.Popup.initialFocus. - Updates z-index handling by scoping
--wp-ui-dialog-z-indexto the dialog portal class.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/editor/src/components/post-actions/style.scss | Adds a portal-scoped --wp-ui-dialog-z-index override for the new Dialog portal. |
| packages/editor/src/components/post-actions/index.js | Reworks PostActions modal actions to use @wordpress/ui Dialog (trigger composition, sizing/focus helpers). |
| packages/editor/CHANGELOG.md | Documents the migration plus behavior parity/bug-fix notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| > | ||
| <DropdownMenuItemTrigger | ||
| action={ action } | ||
| items={ items } |
| // and `packages/dataviews/src/hooks/use-map-focus-on-mount.ts`). The editor | ||
| // package can't depend on dataviews and dataviews can't depend on the editor, | ||
| // so duplication is the least-bad option until the action-modal API is | ||
| // extracted to a neutral package — a tracked follow-up on the parent PR. |
| function mapModalSize( size ) { | ||
| if ( size === 'fill' ) { | ||
| deprecated( "modalSize: 'fill'", { | ||
| since: '15.0.0', |
| // Scope the legacy z-index override to the dialog's portal so the | ||
| // post-actions modal still stacks above older `@wordpress/components` | ||
| // overlays during the transition. The `:root` defaults shared by | ||
| // other migrated overlays come from `@wordpress/dataviews`' |
What
Migrates the duplicated `ActionModal` implementation behind `PostActions` (the editor's "More" menu for the current post) from
@wordpress/components`Modal` to the@wordpress/ui`Dialog` primitive, mirroring the dataviews migration in #78028.Why
`PostActions` carries its own copy of `ActionModal` because `@wordpress/editor` can't depend on `@wordpress/dataviews` (and vice-versa). Keeping the two implementations in lockstep is what makes registered actions behave the same in DataViews tables and in the editor's post menu. This PR brings the editor copy onto `Dialog` so both surfaces share the same animation, dismissal, focus, and `modalSize` behaviour.
How
Testing instructions
Context
This is one of 5 PRs that split #76837. Independent of the others; depends on nothing in that set.