Skip to content

Template field: Disable the field for the front page and the posts page - #87541

Merged
oandregal merged 6 commits into
trunkfrom
update/template-field-is-disabled
Nov 27, 2026
Merged

oandregal merged 6 commits into
trunkfrom
update/template-field-is-disabled

Conversation

@oandregal

@oandregal oandregal commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

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.

How?

  • Template field (@wordpress/core-fields): adds an isDisabled callback to the field, built on a shared isTemplateSwitchable() helper that the field's Edit also uses. Every DataForm with a panel layout now disables the Template button for those pages: quick edit and the inspector alike.
  • Quick edit modals (packages/edit-site and routes/post-list): drop their own front page / posts page checks and the readOnly override, since the field handles it.
  • Page actions (@wordpress/core-actions): after the setting is saved, copy the saved show_on_front, page_on_front, and page_for_posts into the loaded root/__unstableBase record, so every reader of those selectors updates right away.

isDisabled reads 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

  1. Go to Settings > Reading and set a static homepage and posts page.
  2. Open the posts page in the editor. In the inspector, the Template button is disabled and shows the template name.
  3. Open a regular page in the editor: the Template button opens the template control as before.
  4. Go to Pages in the site editor (v1 and the extensible site editor) and open quick edit for the posts page: Template is disabled. For a regular page, it's editable.
  5. Without reloading, use "Set as posts page" on another page.
  6. Open quick edit for both pages: the new posts page's Template is disabled, and the previous posts page's Template is editable.
  7. Repeat steps 5 and 6 with "Set as homepage".

Testing Instructions for Keyboard

  1. In the inspector of the posts page, tab through the fields: Template doesn't open a panel.
  2. In quick edit, tab through the fields after setting a new posts page: only the regular page's Template button opens its panel with Enter.

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.

oandregal and others added 3 commits November 26, 2026 18:27
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>
@oandregal oandregal added the [Type] Bug An existing feature does not function as intended label Nov 27, 2026
Copilot AI balanced review requested due to automatic review settings November 27, 2026 09:29
@oandregal oandregal self-assigned this Nov 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added [Package] Edit Site /packages/edit-site [Package] Fields /packages/fields labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: oandregal <oandregal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +32 B (0%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/modules/core-actions/page.min.js 1.58 kB +98 B (+6.63%) 🔍
build/modules/core-fields/post_type_supports.min.js 82.5 kB +27 B (+0.03%)
build/scripts/edit-site/index.min.js 384 kB -93 B (-0.02%)

65d7761 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 41047c6 trunk % Change
timeToFirstByte 49.05 ms +3.57% -6.63% 45.95 ms +13.28% -3.26% 6.75%
largestContentfulPaint 74 ms +13.51% -2.7% 74 ms +2.7% -8.11% 0%
lcpMinusTtfb 24.6 ms +34.76% -6.1% 24.9 ms +20.68% -6.63% -1.2%
wpBeforeTemplate 25.43 ms +10.34% -4.92% 24.08 ms +14.41% -3.53% 5.61%
wpTemplate 19.1 ms +5.24% -3.61% 18.37 ms +3.27% -5.12% 3.97%
wpTotal 45.25 ms +4.29% -5.9% 42.53 ms +13.78% -3.57% 6.4%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 41047c6 trunk % Change
timeToFirstByte 37.2 ms +11.16% -1.88% 37.8 ms +3.44% -3.44% -1.59%
largestContentfulPaint 68 ms +5.88% -0% 68 ms +0% -5.88% 0%
lcpMinusTtfb 30.1 ms +5.48% -5.48% 28.7 ms +4.7% -3.31% 4.88%
wpBeforeTemplate 20.86 ms +9.97% -3.16% 20.49 ms +5.12% -2.29% 1.81%
wpTemplate 13.88 ms +8.29% -3.53% 13.74 ms +3.78% -5.09% 1.02%
wpTotal 34.44 ms +10.92% -2.24% 34.89 ms +3.61% -4.41% -1.29%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 41047c6 trunk % Change
mediaProcessingJpeg 328.81 ms +0.57% -0.63% 330.06 ms +0.37% -0.95% -0.38%
mediaProcessingAvif 4868.68 ms +0.17% -0.36% 4904.88 ms +0.07% -0.29% -0.74%
mediaProcessingJpegToAvif 3402.35 ms +0.45% -0.14% 3400.89 ms +0.38% -0.22% 0.04%

media-upload

Metric 41047c6 trunk % Change
jpegUploadProcessing 1483.89 ms +1.64% -1.83% 1439.96 ms +2.23% -0.29% 3.05%
pngUploadProcessing 244.76 ms +8.08% -1.14% 241.73 ms +6.62% -5.14% 1.25%
largeJpegUploadProcessing 1442.93 ms +0.93% -0.61% 1436.18 ms +1.46% -0.18% 0.47%
multipleImageUploadProcessing 1534.22 ms +0.49% -1.3% 1554.91 ms +0.77% -2.87% -1.33%

post-editor

Metric 41047c6 trunk % Change
serverResponse 333.93 ms +4.57% -10.09% 333.98 ms +4.35% -7.39% -0.01%
firstPaint 363.68 ms +6.9% -3.81% 343.64 ms +5.92% -1.86% 5.83%
domContentLoaded 681.19 ms +1.12% -0.78% 677.5 ms +1.02% -2.69% 0.54%
loaded 682.26 ms +1.09% -0.79% 678.38 ms +1.02% -2.67% 0.57%
firstContentfulPaint 385.53 ms +1.13% -1.44% 384.6 ms +1.16% -4.51% 0.24%
firstBlock 1846.76 ms +0.91% -1.32% 1803.92 ms +2.36% -0.72% 2.37%
type 15.28 ms +14.07% -4.19% 15.39 ms +4.55% -6.04% -0.71%
typeWithoutInspector 15.62 ms +9.15% -6.02% 14.81 ms +4.79% -8.17% 5.47%
typeWithTopToolbar 20.56 ms +7.34% -4.28% 19.78 ms +1.37% -7.43% 3.94%
typeContainer 7.12 ms +5.2% -11.94% 6.57 ms +3.35% -7.61% 8.37%
focus 89.75 ms +3.92% -3.15% 84.71 ms +1.3% -1.96% 5.95%
firstFocus 207.17 ms +0% -0% 218.09 ms +0% -0% -5.01%
selectAll 305.28 ms +1.88% -2.24% 300.95 ms +0.83% -2.22% 1.44%
undo 24.51 ms +2.94% -8% 24.99 ms +4.92% -4.88% -1.92%
listViewOpen 33.21 ms +9.36% -5.06% 32.45 ms +4.96% -5.49% 2.34%
inserterOpen 35.95 ms +3.42% -10.9% 36.61 ms +9.23% -6.09% -1.8%
inserterHover 9.53 ms +5.46% -7.45% 9.6 ms +12.19% -6.25% -0.73%
inserterSearch 7.38 ms +7.59% -7.59% 7.15 ms +8.11% -1.82% 3.22%
loadPatterns 545.49 ms +1.7% -2.19% 504.43 ms +2.11% -3.36% 8.14%
wpTotal 325.27 ms +4.3% -10.39% 325.25 ms +4.46% -7.57% 0.01%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.34%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 41047c6 trunk % Change
serverResponse 472.75 ms +2.79% -8.55% 466.63 ms +0.78% -7.74% 1.31%
firstPaint 450.09 ms +3.53% -7.37% 432.3 ms +8.97% -8.48% 4.12%
domContentLoaded 845.03 ms +1.93% -0.58% 845.66 ms +1.07% -1.23% -0.07%
loaded 846.04 ms +1.92% -0.58% 846.95 ms +1.03% -1.27% -0.11%
firstContentfulPaint 475.58 ms +3.44% -2.37% 468.46 ms +3.7% -2.92% 1.52%
firstBlock 2656.89 ms +0.73% -0.2% 2614.69 ms +2.28% -0.59% 1.61%
type 18.09 ms +3.81% -4.31% 18.48 ms +7.68% -6.6% -2.11%
navigate 115.67 ms +2.11% -1.86% 123.79 ms +16.44% -9.98% -6.56%
loadPatterns 1338.33 ms +5.78% -3.07% 1402.64 ms +7.14% -3.47% -4.58%
loadPages 973.49 ms +2.15% -3.26% 972.92 ms +1.03% -1.57% 0.06%
wpTotal 463.28 ms +2.73% -8.77% 457.08 ms +0.8% -7.9% 1.36%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

65d7761 Run

🏁 Flaky tests

Some 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 /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-173-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:243:5

Should insert content using the global inserter in /test/e2e/specs/widgets/editing-widgets.spec.js, passed after 1 failed attempt.

region-scoped focus that refrains on traversals in /test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts, passed after 1 failed attempt.
Error: expect(locator).toHaveCount(expected) failed

Locator:  locator('[data-wp-router-region="lifecycle-a"] :focus')
Expected: 0
Received: 1
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" locator('[data-wp-router-region="lifecycle-a"] :focus') with timeout 5000ms
  - waiting for locator('[data-wp-router-region="lifecycle-a"] :focus')
    14 × locator resolved to 1 element
       - unexpected value "1"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigation-lifecycle.spec.ts:1674:37

65d7761 Run

@oandregal oandregal added the [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond label Nov 27, 2026
);
const [ localEdits, setLocalEdits ] = useState< Partial< Post > >( {} );
const { record, hasFinishedResolution, canSwitchTemplate } = useSelect(
const { record, hasFinishedResolution } = useSelect(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here are about removing field-specific logic from the screen. It should live in the field itself (see). This is replaced by making the field itself disabled when it cannot switch templates. As a result, we have the same logic working for quickedit and inspector (fixes #87540).

* @param postId The post id.
* @return Whether the template can be switched.
*/
export function isTemplateSwitchable(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 );

@oandregal oandregal Nov 27, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

oandregal and others added 3 commits November 27, 2026 11:00
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>
@oandregal
oandregal merged commit 33663bb into trunk Nov 27, 2026
87 checks passed
@oandregal
oandregal deleted the update/template-field-is-disabled branch November 27, 2026 10:36
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 27, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] Edit Site /packages/edit-site [Package] Fields /packages/fields [Type] Bug An existing feature does not function as intended

Projects

None yet

2 participants