Skip to content

Navigation: Add an "Auto add new pages" Navigation Menu setting - #84508

Open
jeryj wants to merge 37 commits into
trunkfrom
try/auto-add-pages
Open

jeryj wants to merge 37 commits into
trunkfrom
try/auto-add-pages

Conversation

@jeryj

@jeryj jeryj commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Testing everything together: #87305 is a draft combined build of this PR, #85589 and #87304, with testing steps for all of them. Review stays in the individual PRs.

Closes #85156

What?

Adds an "Auto add new pages" setting to Navigation Menus.

  • While the setting is on, publishing a new page adds a link for it to the menu. A top-level page goes among the menu's page links in page order (menu order, then title), as the Page List block sorts pages. A child page is nested under the link to its parent when the menu has one (a Navigation Link for the parent becomes a Navigation Submenu, keeping its attributes); a menu with no link to the parent is left alone, and so is a menu with a Page List block that already shows the page. A Page List limited to one parent page shows only the pages under it, so other new pages are still added. Existing items are never reordered, renamed or removed, so the menu stays fully editable. This follows _wp_auto_add_pages_to_menu() for classic menus, which only adds top-level pages.
  • The setting is a switch: below the menu's list of links in the Navigation block's List View tab, and pinned to the bottom of the screen in the site editor's navigation sidebar and on the extensible site editor's navigation menu screen. Flipping it is an edit to the menu record, so it is saved with the editor's other changes through the usual save flow, like any other menu edit. The site editor's Duplicate action copies it with the menu. The switch only shows when the menu's REST response lists the setting, so a WordPress release without this PR's server side doesn't show a switch that would reset after saving. On this PR the switch shows the stored value, so a menu with a Page List shows it as off; Page List: Edit pages in place in a Navigation block and turn on Auto add new pages #87304 shows it as on there, since the Page List already shows new pages, and switching it off turns the Page List into links.
  • Publishing a page also invalidates the loaded wp_navigation records in core-data, so a Navigation block on screen picks up the added link without a reload, also when the menu was edited and saved earlier in the session.

The Page List block is untouched, and the default menu a site creates for itself is still a Page List block, as on trunk. Whether that default should change is left for later.

Why?

The Page List block is a live mirror of the page tree, which makes a menu built on it impossible to edit without first detaching it into links, and once detached it no longer picks up new pages. Classic menus solved the same problem fifteen years ago with an append-only "Automatically add new top-level pages" option that coexists with manual editing. This brings that model to block menus.

How?

  • lib/compat/wordpress-7.3/navigation-auto-add-pages.php registers a boolean wp_navigation_auto_add_pages post meta on wp_navigation (and adds custom-fields support so the REST meta field is exposed), and hooks transition_post_status to add links.
  • The link blocks carry the same core/post-data URL binding the Page List "Detach" conversion adds, so permalink changes follow the page. Links to pages that are later unpublished or deleted are already hidden by block_core_shared_navigation_item_should_render().
  • packages/block-library/src/navigation/edit/auto-add-pages-control.tsx and routes/navigation-edit/auto-add-pages-toggle.tsx read the setting from the edited wp_navigation record and change it with editEntityRecord, so the menu shows up as a changed entity in the save panel and saves with everything else. The route gains a dependency on @wordpress/ui for the switch.
  • getEntityRecord.shouldInvalidate in @wordpress/core-data now invalidates wp_navigation records when a page save carrying status: publish is received, following the existing precedent that invalidates the site record when a template is saved. The site editor's menu screen keeps showing the menu while it is fetched again, instead of a spinner, so focus stays put.
  • After a save, core-data keeps the blocks parsed from a record's content as a transient edit, and the editor shows them in place of the content. So a menu edited and saved earlier in the session kept showing its old blocks after the refetch, and its next save dropped the added link. The getEntityRecord resolver now drops a record's transient edits when a refetch brings content that changed on the server, the record has no unsaved changes, and its blocks still serialize to the saved content, so the editor parses the new content. A refetch that brings the same content, of a record with unsaved changes, of blocks holding typing that wasn't saved yet (typing that continues in the same attribute after a save changes only the blocks), or one that started before a save landed, keeps them.
  • The menu is saved with the kses filters on post fields lifted for that one save, at their own priorities, and put back after it, so neither its content nor its title is filtered again. Its existing items were filtered when someone allowed to save them saved them, and filtering them again as the user who publishes the page would strip what that user can't post, such as an icon in a link's label. When that user can't post unfiltered HTML, only the new link's label, the one value that comes from them, is filtered.
  • Publishing a page also makes the editor refetch the page's template and reset its root blocks. The block editor reducer preserved each controlled block's sub-tree across that reset but wrapped it in a new tree entry, so every nested controller (the header template part, and the Navigation block inside it) saw a changed block list and reported it as an edit. When that happened before the Navigation block had applied the refetched menu, the stale edit shadowed the new content until a reload. The reducer now reuses the previous entry when the preserved sub-tree is unchanged, and leaves a controlled block's own entry in place when it already has no inner blocks, so no spurious edit is reported.

Known limitations

  • With submenus set to open on click, a parent page's link that becomes a submenu opens the submenu instead of the page, as a parent page does in a Page List.
  • Undoing an edit made before a link was added brings the menu back as it was then, without the link, and saving it then removes the link. The undo history holds the menu's blocks as they were at each step.
  • When kses changed a menu's content as it was saved (a user without unfiltered_html saving a link URL with &, for example), the editor can't tell its blocks match the saved menu, so it keeps showing them after a page publish, and the next save of the menu drops the added link, as before this PR's refetch handling.
  • Pages published at the same moment in separate requests (bulk publishing from the site editor's Quick Edit saves them in parallel) each read the menu before the others write it, so only the last one's link is kept. Classic menus avoid this by storing each item as its own post.
  • A child page is only added when the menu already links to its parent page by ID. A custom link to the parent's URL does not count, and the child is not added at the top level instead.
  • A link's label is copied when it is created and does not follow a later title change (only the URL is bound).
  • If a menu has unsaved edits while a page is published, saving the menu overwrites the added link. That happens when the menu is open elsewhere, and also in the same editor: publishing a page while its Navigation block's menu has unsaved edits saves both at once, and the menu save can land after the link is added.
  • Changes made in another tab (to a menu, template or pattern) do not reach an already open editor, so a link added by a page published in a different tab shows up on reload or on the next fetch, the same as any other out-of-band edit. This is existing editor behavior and is not addressed here.
  • With the gutenberg-real-time-collaboration experiment on, each wp_navigation post is a synced CRDT document. The append runs server-side through wp_update_post, outside that document, so a collaboration client already holding the menu does not learn about the link and its next save of the menu writes its own copy back over it. Routing the append through the sync layer is a separate change.

Side effects

  • wp_navigation gains custom-fields support so the setting's meta is exposed through REST. The Real-Time Collaboration experiment decides which post types sync by that same support, so with the experiment on, Navigation Menus become collaborative entities and the CRDT document is persisted into the menu's post meta on save. On trunk they are excluded. This is noted here so it is a deliberate change: the menu is edited through the Navigation block inside another post's editor rather than as the current post, and that path has not been exercised with collaboration yet.
  • Adding custom-fields support also registers the footnotes meta on wp_navigation (register_block_core_footnotes_post_meta() registers it for every post type that supports editor, custom-fields and revisions). Menus then expose an empty meta.footnotes in REST and keep it in their revisions.
  • Each page publish saves every opted-in menu that gains a link, so each one gets a new revision. Importing or bulk-publishing many pages adds a revision per page to each such menu.
  • The menu is saved without the content kses filter (see How?), including when the page publishes from cron or as a user without unfiltered_html; only the new link's label is filtered for that user. PHPUnit tests cover both, with an existing item whose label and URL kses would change.
  • This is the first place in the project where the server edits a Navigation Menu's block markup outside the editor's own save (see "Known limitations" for the open-editor race).

Testing Instructions

  1. On a site with a few published pages (including a child page), insert a Navigation block. It starts as a Page List, as on trunk. Select the Page List, choose Detach in its toolbar and confirm, so the menu holds links.
  2. With the Navigation block selected, open its List View tab. Turn "Auto add new pages" on below the menu's links: the top bar button becomes "Save" and the save panel lists the menu. Save it.
  3. Publish a new top-level page. Reload the editor or the front end: a link to it is added to the menu, in page order. Publish a child of a page that is in the menu: its parent's link becomes a submenu holding the new link.
  4. Turn the switch off. Publish another page: the menu does not change.
  5. With the gutenberg-extensible-site-editor experiment on, open Appearance > Navigation, open a menu. Flip the switch below the menu's links: the "Review 1 change…" button appears, and saving from it stores the setting.
  6. In the post editor with "Show template" on, publish a new page: the Navigation block in the header shows the new link without a reload.

Automated coverage: phpunit/navigation-auto-add-pages-test.php, test/e2e/specs/editor/blocks/navigation-auto-add-pages.spec.ts (including the "Show template" case with the menu in the header template part) and test/e2e/specs/site-editor/navigation-auto-add-pages.spec.ts, plus a block editor reducer unit test for the reset behavior and core-data resolver unit tests for the refetch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 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: jeryj <jeryj@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: 369work <369work@git.wordpress.org>
Co-authored-by: mikachan <mikachan@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 or WordPress.org 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: +3.32 kB (+0.04%)

Total Size: 8.86 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 563 kB +39 B (+0.01%)
build/scripts/block-library/index.min.js 436 kB +2.67 kB (+0.62%)
build/scripts/core-data/index.min.js 78.8 kB +178 B (+0.23%)
build/scripts/edit-site/index.min.js 377 kB +99 B (+0.03%)
build/styles/block-library/editor-rtl.css 13.1 kB +38 B (+0.29%)
build/styles/block-library/editor-rtl.min.css 10.8 kB +33 B (+0.31%)
build/styles/block-library/editor.css 13.2 kB +37 B (+0.28%)
build/styles/block-library/editor.min.css 10.8 kB +33 B (+0.31%)
build/styles/block-library/navigation/editor-rtl.css 3.47 kB +52 B (+1.52%)
build/styles/block-library/navigation/editor-rtl.min.css 2.38 kB +44 B (+1.88%)
build/styles/block-library/navigation/editor.css 3.48 kB +53 B (+1.55%)
build/styles/block-library/navigation/editor.min.css 2.38 kB +48 B (+2.05%)

04eca01 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric acc37f4 trunk % Change
timeToFirstByte 57 ms +9.39% -2.81% 58.5 ms +9.15% -4.96% -2.56%
largestContentfulPaint 92 ms +4.35% -8.7% 92 ms +4.35% -4.35% 0%
lcpMinusTtfb 29.4 ms +23.47% -3.57% 29.8 ms +24.66% -5.54% -1.34%
wpBeforeTemplate 29.99 ms +18.21% -1.6% 30.81 ms +10.29% -3.64% -2.66%
wpTemplate 22.65 ms +4.15% -2.52% 23.43 ms +4.14% -6.87% -3.33%
wpTotal 53.05 ms +9.99% -2.79% 54.52 ms +9.98% -5.3% -2.7%
wpMemoryUsage 7.77 MB +0% -0% 7.72 MB +0% -0% 0.56%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric acc37f4 trunk % Change
timeToFirstByte 47.5 ms +5.68% -1.47% 49 ms +3.98% -3.06% -3.06%
largestContentfulPaint 84 ms +2.38% -0% 84 ms +2.38% -0% 0%
lcpMinusTtfb 35.6 ms +4.21% -4.78% 35.25 ms +3.4% -3.12% 0.99%
wpBeforeTemplate 27.6 ms +5.8% -1.63% 27.81 ms +6.04% -0.76% -0.76%
wpTemplate 16.61 ms +3.49% -1.99% 17.02 ms +4.41% -2.82% -2.41%
wpTotal 44.38 ms +6.02% -1.33% 45.44 ms +5.02% -2.6% -2.33%
wpMemoryUsage 6.45 MB +0% -0% 6.41 MB +0% -0% 0.68%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric acc37f4 trunk % Change
mediaProcessingJpeg 401.22 ms +0.71% -1.18% 401.29 ms +0.56% -1.58% -0.02%
mediaProcessingAvif 6152.44 ms +0.06% -0.21% 6125.55 ms +0.1% -0.16% 0.44%
mediaProcessingJpegToAvif 4238.23 ms +0.55% -0.33% 4210.92 ms +0.34% -0.26% 0.65%

media-upload

Metric acc37f4 trunk % Change
jpegUploadProcessing 2004.33 ms +2.67% -21.99% 1746.12 ms +13.11% -12.57% 14.79%
pngUploadProcessing 279.69 ms +5.16% -2.84% 277.77 ms +1.23% -3.44% 0.69%
largeJpegUploadProcessing 1736.18 ms +14.06% -14.08% 1970.98 ms +0.58% -23.23% -11.91%
multipleImageUploadProcessing 2073.26 ms +0.9% -0.8% 2123.91 ms +2.26% -1.57% -2.38%

post-editor

Metric acc37f4 trunk % Change
serverResponse 478.19 ms +1.59% -8.5% 462.58 ms +5.79% -4.63% 3.37%
firstPaint 445.1 ms +5.63% -17.92% 388.11 ms +11.64% -4.56% 14.68%
domContentLoaded 826.55 ms +1.18% -2.25% 805.02 ms +3.06% -0.76% 2.67%
loaded 827.92 ms +1.18% -2.24% 806.32 ms +3.03% -0.75% 2.68%
firstContentfulPaint 458.53 ms +6.56% -1.7% 449.06 ms +2.53% -1.45% 2.11%
firstBlock 2192.55 ms +1.6% -1.08% 2185.22 ms +0.52% -0.81% 0.34%
type 16.69 ms +11.2% -3.83% 16.82 ms +3.63% -4.88% -0.77%
typeWithoutInspector 16.62 ms +8.54% -9.93% 17.57 ms +3.98% -7.4% -5.41%
typeWithTopToolbar 22.15 ms +6.95% -3.48% 22.03 ms +7.58% -7.85% 0.54%
typeContainer 8.12 ms +7.76% -4.19% 8.23 ms +8.02% -14.58% -1.34%
focus 106.67 ms +5.14% -2.72% 105.9 ms +10.65% -5.04% 0.73%
firstFocus 284.59 ms +0% -0% 272.7 ms +0% -0% 4.36%
selectAll 390.45 ms +1.12% -1.9% 379.81 ms +2.81% -0.35% 2.8%
undo 28.09 ms +4.63% -3.67% 27.7 ms +7.62% -2.78% 1.41%
listViewOpen 39 ms +7.05% -7.56% 39.93 ms +2.85% -12.55% -2.33%
inserterOpen 37.85 ms +9.78% -8.38% 43.05 ms +7.5% -14.01% -12.08%
inserterHover 10.64 ms +9.68% -9.02% 11.27 ms +12.95% -7.01% -5.59%
inserterSearch 8.43 ms +9.02% -3.44% 7.94 ms +2.9% -9.7% 6.17%
loadPatterns 610.81 ms +13.09% -4.13% 659.02 ms +6.55% -9.42% -7.32%
wpTotal 468.5 ms +1.63% -8.64% 452.86 ms +5.97% -4.69% 3.45%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric acc37f4 trunk % Change
serverResponse 404.33 ms +0.62% -10.82% 405.09 ms +2.04% -10.64% -0.19%
firstPaint 457.82 ms +3.2% -14.59% 474.68 ms +1.82% -6.1% -3.55%
domContentLoaded 842.73 ms +1.36% -1.78% 838.07 ms +4.15% -1.37% 0.56%
loaded 844.1 ms +1.36% -1.77% 839.43 ms +4.13% -1.36% 0.56%
firstContentfulPaint 467.68 ms +4.88% -1.93% 474.68 ms +8.37% -5.87% -1.47%
firstBlock 2568.12 ms +3.81% -1.23% 2541.32 ms +2.31% -2.07% 1.05%
type 18.01 ms +3.22% -8.55% 23.94 ms +21.93% -15.08% -24.77%
navigate 109 ms +16.26% -1.76% 104.53 ms +9.67% -0.66% 4.28%
loadPatterns 1568.48 ms +4.89% -18.95% 1411 ms +6.8% -13.5% 11.16%
loadPages 921.22 ms +1.23% -2.03% 929.16 ms +3.76% -2.73% -0.85%
wpTotal 393.78 ms +0.62% -11.07% 394.36 ms +2.07% -10.89% -0.15%
wpMemoryUsage 12.85 MB +0% -0% 12.80 MB +0% -0% 0.38%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

04eca01 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.

adds one note to every selected block in /test/e2e/specs/editor/various/block-notes.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByRole('button', { name: 'Dismiss this notice' }).filter({ hasText: 'Note deleted.' })
Expected: visible
Error: strict mode violation: getByRole('button', { name: 'Dismiss this notice' }).filter({ hasText: 'Note deleted.' }) resolved to 2 elements:
    1) <div tabindex="0" role="button" data-testid="snackbar" class="components-snackbar" aria-label="Dismiss this notice">…</div> aka getByTestId('snackbar').nth(1)
    2) <div tabindex="0" role="button" data-testid="snackbar" class="components-snackbar" aria-label="Dismiss this notice">…</div> aka getByTestId('snackbar').nth(3)

Call log:
  - Expect "toBeVisible" getByRole('button', { name: 'Dismiss this notice' }).filter({ hasText: 'Note deleted.' }) with timeout 5000ms
  - waiting for getByRole('button', { name: 'Dismiss this notice' }).filter({ hasText: 'Note deleted.' })

    at BlockNoteUtils.deleteNote (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes-utils.js:301:53)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes.spec.js:3085:5
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes.spec.js:3071:4

04eca01 Run

@github-actions github-actions Bot added the [Package] Core data /packages/core-data label Oct 10, 2026
@jeryj jeryj added [Type] Enhancement A suggestion for improvement. [Block] Navigation Affects the Navigation Block labels Oct 10, 2026
@jeryj jeryj changed the title Navigation: Add an "Auto add pages" menu setting and replace the Page List fallback Navigation: Replace default Page List block with "Auto add pages" Navigation block setting Oct 10, 2026
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Oct 14, 2026
jeryj and others added 8 commits October 20, 2026 13:27
…st fallback

Register a boolean `wp_navigation_auto_add_pages` meta on Navigation Menus. While it is on, publishing a top-level page appends a link to the menu, the way classic menus do; existing items are never touched. The default menu a site creates for itself is now built from link blocks, one per published page, nested like the Page List block rendered them, with the setting on.

The setting is a switch in the Navigation block's Settings tab and on the extensible site editor's navigation menu screen.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The server appends a link to every menu with "Auto add pages" on, but the editor keeps its copy of the menu until a reload. Invalidate the loaded `wp_navigation` records when the page publish is received, the way saving a template invalidates the site record, so a Navigation block on the screen refetches and shows the new link.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
…ve button

The navigation menu screen already saves the menu's items through the global Save button, so the setting becomes a pending edit to the same record instead of saving on its own.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The setting is saved on its own in both the block inspector and the extensible site editor's navigation screen, so it never appears as a pending change in a save flow. Only the setting is sent; the menu's items are left to the editor's own save.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
… root reset

When the root blocks are reset, the reducer preserves each controlled block's sub-tree but wrapped it in a new tree entry, so every nested controller saw a changed block list and reported it as an edit it did not make. Publishing a page refetches the template and resets the root blocks, and the Navigation block inside the header template part could report its stale children before it had applied the menu content refetched from the server, hiding the appended link until a reload.

Reuse the previous entry when the preserved sub-tree is unchanged, and cover the "Show template" case in the auto-add e2e spec.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
…ve flow

The setting is an edit to the menu record, so it now goes through
`editEntityRecord` and is saved with the editor's other changes, like any
other menu edit. The self-saving handler, its saving state and error notice
are removed from both the block control and the extensible site editor
toggle.

The extensible site editor screen uses a Stack with a gap to space the
toggle from the menu editor instead of a one-off margin rule.

The two e2e tests that asserted the setting saved on its own now assert that
the Save or Review changes button appears and that saving stores the setting.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RKwLg37vPNWxb2pUbFB6mS
The "Auto add pages" hook skipped child pages, as classic menus do. It now
adds a child page under the link to its parent when the menu has one: a
Navigation Link for the parent becomes a Navigation Submenu with the same
attributes, and an existing submenu gets the child appended. A menu with no
link to the parent is left alone, so no orphan links are added.

The page-link check is split out so the same match rule (page ID with the
post-type kind or page type) finds the parent block.

The toggle descriptions and the meta description no longer say "top-level".

PHPUnit covers the link-to-submenu conversion, appending to an existing
submenu, a grandchild, and a parent that is only linked by URL. The e2e spec
publishes a child page and checks that the navigation block shows the parent
as a submenu holding the child without a reload.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
@jeryj
jeryj marked this pull request as ready for review October 20, 2026 18:37
@jeryj
jeryj force-pushed the try/auto-add-pages branch from 0bb40a2 to b3a1096 Compare October 20, 2026 18:37
Creating a published page from the Navigation block's link UI fires the auto-add hook before the editor has saved its own link. The hook appends a link on the server, and the editor's pending block edit shadows that copy and overwrites it on save, so the menu ends up with a single link. Add an e2e test that documents this flow and asserts the saved menu links to the new page exactly once.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
jeryj and others added 3 commits October 26, 2026 15:42
…ent user

A scheduled page publishes from cron with no user, so kses filters the menu content on save. Cover that path alongside the existing author test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
With no current user, kses filters the menu content on save and entity-encodes string attributes such as labels. The no-user test now covers an existing link next to the auto-added one, and the test helper slashes fixture content the way wp_insert_post expects.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
…hanged

The no-user test compared an existing label against the entity-encoded form kses produces, which pins kses behavior the feature does not own. Compare the existing link block before and after the save instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot where is the Playground link for this PR?

Open this PR in WordPress Playground.

The latest successful plugin build I found is for 01e816e, before the current f6bc656 commit, so the preview may not include the latest wording change.

Add the "Auto add new pages" setting without deciding what the default menu should be. The menu a site creates for itself is a Page List block again, as on trunk. The fallback filter, the page tree builders only it used and their tests are removed, and the default menu tests are back to trunk's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeryj jeryj changed the title Navigation: Replace default Page List block with "Auto add new pages" Navigation block setting Navigation: Add an "Auto add new pages" Navigation Menu setting Nov 24, 2026
@github-actions
github-actions Bot requested review from aduth and ciampo November 24, 2026 19:12
jeryj and others added 9 commits November 24, 2026 14:13
It goes in among the menu's page links in page order, so the file comment and the changelog now only say it is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The site editor's Duplicate action copied only the title and content, so the copy of a menu with the setting on had it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts were the changelogs and the controlled block reset in the block editor reducer. Trunk now leaves a controlled block's own tree entry without inner blocks on reset, and replaced that entry with a new object even when it already had none, which broke the stable reference for a nested controller. It is now replaced only when it has inner blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trunk now requires new files in the e2e tests to be TypeScript (#84829). Menus with the setting on are created through the REST API, since `createNavigationMenu()` takes only a title and content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/block-editor/CHANGELOG.md
#	packages/block-library/CHANGELOG.md
#	packages/block-library/src/private-apis.js
#	packages/core-data/CHANGELOG.md
…mpat folder

WordPress 7.2 has branched, so new features now target 7.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The WordPress 7.3 compat folder is analyzed at PHPStan's strict level. Give the block arrays value types, read nested block fields only when they are arrays, and state the void returns. A link whose page ID isn't numeric is skipped, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… site editor screens

In the site editor's navigation sidebar, the setting is now the screen's footer, which sticks to the bottom of the sidebar. In the extensible site editor, it sits at the bottom of the menu screen and stays there while the list scrolls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeryj and others added 9 commits December 2, 2026 09:39
# Conflicts:
#	packages/block-editor/CHANGELOG.md
#	packages/block-library/CHANGELOG.md
#	packages/block-library/src/navigation/edit/menu-inspector-controls.tsx
# Conflicts:
#	packages/core-data/CHANGELOG.md
# Conflicts:
#	packages/block-library/CHANGELOG.md
…eside scoped Page Lists

- core-data: when a refetch brings content that changed on the server and the record has no unsaved changes, drop the blocks kept as a transient edit since its last save. A menu edited and saved earlier in the session now shows the link a page publish added, and its next save keeps it.
- Save the menu with kses off and filter only the new link's label when the publisher can't post unfiltered HTML, so a page publish no longer strips the menu's existing markup or encodes its URLs.
- Skip a menu only when one of its Page Lists shows the new page. A Page List limited to one parent page no longer stops other pages from being added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- core-data: drop a refetched record's transient blocks only when they still serialize to the saved content, so typing that continued in the same attribute after a save isn't lost.
- Lift only the `content_save_pre` kses filter, at its own priority, for the menu save, instead of removing and re-adding every kses filter, so a site's other kses settings stay as they were.
- Read a Page List's `parentPageID` as the block validates it, and count a page as listed only when its parent pages up to the Page List's are published, as the Page List renders them.
- Correct the docblock on nesting: with submenus set to open on click, the parent's item opens the submenu, as in a Page List.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- core-data: don't drop a refetched record's transient blocks when a save changed its stored content while the request was out, since the response is then older than what was saved.
- Lift every kses filter on the post fields for the menu save, at their own priorities, so the menu's title isn't filtered again either.
- Sort titles by the new link ignoring accents as well as case, closer to the database collation the Page List sorts by.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Render the switch only when the menu's REST meta lists the setting, so a WordPress release without the server side doesn't show a switch that resets after saving.
- Keep the site editor's menu screen in place while the menu is fetched again after a page publish, instead of swapping it for a spinner, which dropped focus.
- Describe the setting as "Adds pages to this navigation when they are published.", the wording the Page List PR uses: the old copy said existing pages are never added, but a draft is added when it publishes.
- Cover `getEntityRecord.shouldInvalidate` for menus with unit tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Leave the site editor's menu screen without its footer when the menu has no "Auto add new pages" setting, instead of an empty bordered bar, as the extensible site editor already does.
- Read the transient blocks through `select?.` like the saved content, in the resolver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Navigation Affects the Navigation Block [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Core data /packages/core-data [Package] Edit Site /packages/edit-site [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navigation: Add Auto add page navigation block setting

3 participants