Edit Site: Migrate Page Templates duplicate dialog from Modal to @wordpress/ui Dialog#78030
Edit Site: Migrate Page Templates duplicate dialog from Modal to @wordpress/ui Dialog#78030ciampo wants to merge 2 commits into
Modal to @wordpress/ui Dialog#78030Conversation
Replaces the legacy `@wordpress/components` `Modal` wrapper around `duplicateAction.RenderModal` with `<Dialog.Root>` + `<Dialog.Popup>` so this consumer hosts the migrated `RenderModal` inside a real `Dialog` ancestor (a prerequisite for the action's `Cancel` button to move to `Dialog.Action`). The dialog uses a separate "is open" state so the cached template clears on `onOpenChangeComplete` rather than mid-animation, keeping the popup contents rendered through the exit transition.
Two small safeguards against the mid-animation re-open race:
- Defensive setter inside `onOpenChangeComplete` so a late "closed"
callback (firing after the user has already re-opened the dialog with
a different template) is ignored instead of nulling the active
selection mid-session.
- `key={ selectedRegisteredTemplate.id }` on `<duplicateAction.RenderModal>`
so switching templates while the dialog is still closing remounts the
inner component with a fresh `useState` initializer — otherwise the
previous template's "(Copy)" title persists into the new session.
Same-template re-open intentionally keeps state (no key change), which
matches the user's likely intent of returning to in-progress edits.
|
Size Change: +47.6 kB (+0.6%) Total Size: 8 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 4f7d353. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25447114387
|
|
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
Migrates the Edit Site “Duplicate registered template” overlay in the Page Templates list from @wordpress/components Modal to the @wordpress/ui Dialog primitive, aligning this last non-DataViews action surface with the broader Dialog migration work.
Changes:
- Replaces the
Modalwrapper withDialog.Root/Dialog.Popup(small size) and controls visibility viaopen/onOpenChange. - Preserves exit animation by deferring
selectedRegisteredTemplateteardown toonOpenChangeComplete, and keys the innerRenderModalby template id to force a clean remount on fast re-opens. - Adds an edit-site changelog entry documenting the migration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/edit-site/src/components/page-templates/index.js | Wraps the duplicate action UI in @wordpress/ui Dialog and adjusts state lifecycle for animation-safe teardown/remounting. |
| packages/edit-site/CHANGELOG.md | Notes the migration in the Unreleased “Code Quality” section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| onOpenChangeComplete={ ( isOpen ) => { | ||
| if ( ! isOpen ) { | ||
| // Clear the cached template only after the exit | ||
| // animation finishes — keeps the modal contents | ||
| // rendered while the dialog slides out so the | ||
| // inner DataForm doesn't flash empty. The | ||
| // functional setter guards against a stale | ||
| // "complete" callback firing after the user has | ||
| // already re-opened the dialog with a different | ||
| // template (mid-animation re-open race). | ||
| setSelectedRegisteredTemplate( ( prev ) => | ||
| isDuplicateOpen ? prev : false | ||
| ); |
What
Migrates the duplicate-registered-template dialog in Edit Site's Page Templates list from
@wordpress/components`Modal` to the@wordpress/ui`Dialog` primitive.Why
This is the only DataViews-style action surface in Edit Site that wasn't already migrated to `Dialog`, because the registered-template duplicate flow is hosted by edit-site directly rather than through a DataViews item-action menu. Bringing it onto `Dialog` removes a leftover `Modal` consumer and makes its behaviour consistent with the rest of the migration sweep (animations, portal, dismissal semantics).
How
Testing instructions
Context
This is one of 5 PRs that split #76837. Independent of the others; can be reviewed/merged on its own.