Repository navigation
Template field: Disable the field for the front page and the posts page - #87541
Conversation
The reading settings assign the template of these pages, so the field can't change it. The control already disabled itself; `isDisabled` now disables the whole field, so every DataForm gets it without overriding the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The template field now knows when it can't switch the template, so the quick edit modals no longer make it read-only themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Set as homepage" and "Set as posts page" save the `root/site` entity, but `getHomePage()` and `getPostsPageId()` read the pages from `root/__unstableBase`, which the save left untouched. Until the next load, everything built on those selectors kept the previous pages: the template field stayed disabled for the old posts page and editable for the new one. Copy the saved reading settings into the loaded base data once the save succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +32 B (0%) Total Size: 8.73 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the list via UP/DOWN arrow keys from action buttons in
|
| ); | ||
| const [ localEdits, setLocalEdits ] = useState< Partial< Post > >( {} ); | ||
| const { record, hasFinishedResolution, canSwitchTemplate } = useSelect( | ||
| const { record, hasFinishedResolution } = useSelect( |
There was a problem hiding this comment.
| * @param postId The post id. | ||
| * @return Whether the template can be switched. | ||
| */ | ||
| export function isTemplateSwitchable( |
There was a problem hiding this comment.
This centralizes the logic that was across QuickEdit and the field's Edit.
|
|
||
| // `getHomePage()` and `getPostsPageId()` read the base data of the | ||
| // site, which the save doesn't update. | ||
| syncSiteBase( registry, savedSettings ); |
There was a problem hiding this comment.
This modal is used by the two actions: "set as homepage", "set as posts page" that change the site setting. syncSiteBase updates and syncs the corresponding setting immediately when it changes (previously, it required reloading the page).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reading settings assign the template of the posts page, so the field no longer offers an edit button there. Check the value it shows and that the button is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…test The Vitest conventions require vi.mock( import( ... ) ) in TypeScript tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What?
Closes #87539
Closes #87540
Moves the rule that disables the template field for the front page and the posts page from the quick edit modals into the field itself, and keeps that rule up to date after "Set as homepage" or "Set as posts page".
Why?
The front page and the posts page get their template from the reading settings, so the template field can't change it.
root/site, butgetHomePage()andgetPostsPageId()readroot/__unstableBase, which the save didn't update. Until a reload, the template stayed locked for the previous page and editable for the new one.How?
@wordpress/core-fields): adds anisDisabledcallback to the field, built on a sharedisTemplateSwitchable()helper that the field'sEditalso uses. Every DataForm with a panel layout now disables the Template button for those pages: quick edit and the inspector alike.packages/edit-siteandroutes/post-list): drop their own front page / posts page checks and thereadOnlyoverride, since the field handles it.@wordpress/core-actions): after the setting is saved, copy the savedshow_on_front,page_on_front, andpage_for_postsinto the loadedroot/__unstableBaserecord, so every reader of those selectors updates right away.isDisabledreads the stores through the default registry when the form renders and doesn't subscribe to them. The editor and the v2 site editor load the base site data before they render, so it's there in time.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Recorded on a test site where "Home" is the homepage and "Blog" is the posts page. "Before" is trunk at the base of this branch.
Inspector (#87540)
The posts page's Template field in the inspector.
Before: the field opens, and its panel holds a disabled control.
before-87540.mp4
After: the field is disabled, as in quick edit.
after-87540.mp4
Set as posts page (#87539)
Set "About" as the posts page, then quick edit "About" and "Blog" without reloading.
Before: "About"'s template stays editable and "Blog"'s stays locked.
before-87539.mp4
After: "About"'s template is locked and "Blog"'s is editable.
after-87539.mp4
Use of AI Tools
Claude Code (Claude Opus 5.5) helped write the changes, the unit tests, and this description; I reviewed them.