Skip to content

[Do not merge] Navigation: Auto add new pages, combined build for testing - #87305

Draft
jeryj wants to merge 122 commits into
trunkfrom
try/auto-add-pages-combined
Draft

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

Conversation

@jeryj

@jeryj jeryj commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Do not merge. A combined build of the "Auto add new pages" work, for testing it all together. Review and merge happens in the individual PRs.

Testing Instructions

  1. On a site with no Navigation Menus and a few published pages (one with a child page), insert a Navigation block. Its default menu is a Page List, as on trunk, and shows its pages as links. Delete one of them: the Page List becomes links, and "Auto add new pages" in the block's List View tab stays on.
  2. Publish a new page: a link to it is added at the end of the menu.
  3. Permanently delete a page that is in the menu: its link is removed.
  4. Edit a menu that holds a Page List of all pages. Its pages are selectable menu items, and "Auto add new pages" shows as on. Move, delete, rename, or add a link among them: the Page List becomes links and the setting stays on. Switching the setting off instead turns the Page List into links with the setting off. One undo reverts it, except after typing a new label, which takes two undos until Block Editor: Stop duplicate controllers from taking the selection #82706 lands.
  5. With a link right before the Page List, its "Move right" arrow moves it past one page, not the whole list. In the List View tab, Options > Move down on a link above an expanded submenu moves it into the submenu, and past it when the submenu is collapsed.
  6. With the gutenberg-extensible-site-editor experiment on, repeat 4 and 5 on Appearance > Navigation. The setting sits at the bottom of the menu screen.

🤖 Generated with Claude Code

jeryj and others added 29 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
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
…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
…f links

The setting belongs to the menu's content, not to the block, so it follows the List View of the menu's links in every place that list is shown: the block inspector's List View tab, the site editor's navigation sidebar, and the extensible site editor's navigation menu screen. It leaves the block's Settings tab, and the control guards itself with the user's permission to update the menu.

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

The description now reads "Automatically adds newly published pages to this navigation." The control sits below a line, with more room above and below it, so it reads as a setting of the menu rather than as another item in its list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
When a post or term is permanently deleted, remove every Navigation Link block bound to it from every Navigation Menu, the way classic menus drop their items on delete_post and delete_term. A link is bound when its URL follows the post or term through a core/post-data or core/term-data block binding, which the link UI sets up for a link picked from the site's content. A link with a typed-in URL is left alone. A bound Navigation Submenu keeps its label and inner blocks and loses only its link attributes, so the menu structure stays in place. Trash and unpublish are unchanged, since the blocks already skip unpublished content when they render.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
Drop only the removed block's placeholder from the parent's innerContent instead of rebuilding it, so a wrapper block with its own HTML keeps that HTML. Match the ID prefilter with optional whitespace around the colon. Cover a deletion with no current user, where kses re-encodes the menu content on save.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
Compare the remaining blocks before and after the save instead of pinning the entity encoding kses applies to labels.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
# Conflicts:
#	packages/block-editor/CHANGELOG.md
#	packages/block-library/CHANGELOG.md
#	packages/core-data/src/resolvers.ts
#	routes/navigation-edit/tsconfig.json
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199oMWAas4xDSnjTYeDtPxL
The label names what the switch does to future pages, and the help text
now says when they are added instead of repeating the label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vfDfpUYw8PAkEUWnB7
A newly published page now goes in among its sibling page links in page
order (menu order, then title), as the Page List block sorts pages, instead
of at the end. A menu with a Page List block is left alone, since the Page
List already shows the page.

The default menu callback now runs last on
`wp_navigation_should_create_fallback`, so a theme or plugin returning
false stops it from creating the menu.

The help text now says the setting applies only to pages published from
now on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vfDfpUYw8PAkEUWnB7
A newly published top-level page goes at the end of the menu, and a child
page goes at the end of its parent's submenu, instead of among its sibling
page links in page order. A menu someone has rearranged keeps its order,
and the new link is easy to find.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside a Navigation block, the Page List shows its pages as Navigation
Links and Submenus, which can be selected with one click and edited like
the menu's other links. It stays a live Page List until one of them is
changed: moved, removed, relabeled, or a link is added or dropped among
them. Then the Page List is replaced by the links as they are after that
change, and the menu's "Auto add new pages" setting is switched on, so
new pages keep arriving. One undo reverts both.

- The links are rebuilt only when the page data changes. The pages query
  returns a new array whenever a single page record is received, which
  replaced the links (and dropped a selection) shortly after load.
- The list opts out of the block overlay. Outside a Navigation block a
  click on a page selects the Page List itself, as before.
- The list's container gets the Navigation Submenu's settings, so its
  links get "Add before" and "Add after".
- With more than 100 pages the list stays as it is, since the query stops
  at 100 and converting would drop the rest.
- The "Auto add new pages" setting is hidden while the menu has a Page
  List, in the block inspector and on the extensible site editor's
  navigation screen.
- The setting's description is back to "Adds pages to this navigation
  when they are published."

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

On the extensible site editor's navigation screen, the setting sits at the
bottom of the menu area, under a full-width line that matches the page
header's border. When the menu is taller than the screen, it follows the
last item and is reached by scrolling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge List pages

A one-step move (Move up/down, Move left/right, and their shortcuts) now
goes to the next place the person can see, instead of past the next
sibling block whatever it holds.

- In the Navigation List Views (the block inspector's List View tab, the
  site editor's navigation sidebar, and the extensible site editor's
  navigation screen), "Move down" past an expanded submenu puts the item
  in it as the first child, and past a collapsed one goes past it. The
  first or last child of a submenu moves out of it.
- Inside a Navigation block, the Page List's links count as the menu's
  own items. A neighbor moves past one page at a time instead of the
  whole list, the first and last page can move out, and a submenu among
  the pages is never entered from the canvas. Moving across the list's
  edge converts it to links, and one undo reverts the move and the
  conversion.

How: a private `getBlockMoveDestination` selector works out where one step
lands, given which containers count as expanded and which are
transparent. Blocks opt in to being transparent with the private
`setBlockMoveTransparent` action; the Page List does in a Navigation
block. `moveBlocksUp` and `moveBlocksDown`, and the mover buttons'
disabled state, use it with nothing expanded. List View passes its own
expanded state to custom row menus through the private
`useListViewMoveDestination` hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeryj and others added 30 commits December 2, 2026 10:54
# 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>
…rts-on-edit

# Conflicts:
#	lib/compat/wordpress-7.3/navigation-auto-add-pages.php
A Page List limited to one parent page shows only the pages under it, and the server now adds other new pages next to it. So such a menu shows the setting as saved, and switching the setting off converts only Page Lists of all pages.

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>
…rts-on-edit

# Conflicts:
#	lib/compat/wordpress-7.3/navigation-auto-add-pages.php
#	packages/block-library/src/navigation/edit/auto-add-pages-control.tsx
#	phpunit/navigation-auto-add-pages-test.php
#	routes/navigation-edit/auto-add-pages-toggle.tsx
#	routes/navigation-edit/stage.tsx
#	test/e2e/specs/site-editor/navigation-auto-add-pages.spec.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rts-on-edit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-pages-combined

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a menu with a Page List of all pages, creating a page from an appender's link UI also added a link to it, while the Page List showed the page too, so the menu listed it twice. The link UI now closes without a link in that case, which removes the new link, and the Page List shows the page once it is published. A link that already has a URL, a submenu, and a menu whose Page List is limited to one parent page keep the link as before.

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

Leaving the new page to the Page List made the create flow look like it did nothing: the link UI closed, and the page showed up inside the Page List in page order rather than where it was added. The create flow adds its link again, and now turns the menu's Page Lists of all pages into links first, by moving each one's first link out to where the Page List is. That is an edit to the Page List's links, so it converts the Page List and turns "Auto add new pages" on, as the menu's other edits do. The page then shows once, as the new link.

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

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Core data /packages/core-data [Package] Edit Site /packages/edit-site

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant