Skip to content

Navigation: Give imported classic menus distinct titles - #85443

Open
salvatorecorsi wants to merge 18 commits into
WordPress:trunkfrom
salvatorecorsi:fix/39200-deduplicate-imported-navigation-titles
Open

salvatorecorsi wants to merge 18 commits into
WordPress:trunkfrom
salvatorecorsi:fix/39200-deduplicate-imported-navigation-titles

Conversation

@salvatorecorsi

@salvatorecorsi salvatorecorsi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #39200.

Give each newly imported classic menu an available Navigation menu title. Importing Primary twice creates Primary and Primary 2 instead of two Navigation menus named Primary.

Why?

The classic-menu converter supplies the classic menu name to useCreateNavigationMenu, which previously skipped the existing default-title generator whenever a name was supplied. Repeated imports therefore saved indistinguishable names. The existing automatic naming algorithm could also select an already used suffix when names had gaps.

How?

Allow the title generator to receive a preferred title and use it for every Navigation menu creation. Wait for both draft and published menus, then select the first available exact title using numeric suffixes. Names that merely share a prefix do not cause a collision. Existing template-area naming, preview behavior, block serialization, post status and save flow are preserved; manually renaming an existing menu is unaffected.

The regression tests exercise the real classic-menu converter, creation hook, title generator and core-data registry, with mocked REST transport at the boundary. They cover sequential imports, draft and published collisions, suffix gaps, literal numeric suffixes, escaped titles, asynchronous resolution, template-area fallback and preview/error controls.

Testing Instructions

  1. Create a classic menu called Primary with at least one link.
  2. Insert a Navigation block in the editor and open its menu selector.
  3. Choose Primary under Import Classic Menus.
  4. Open the selector and import the same classic menu again.
  5. Confirm the two imported Navigation menus have distinct names (Primary and Primary 2) and retain the same links.
  6. With Primary, Primary 2 and Primary 4 already present as draft or published Navigation menus, repeat the import and confirm the new name is Primary 3.

Testing Instructions for Keyboard

Select the Navigation block, use Tab to reach its menu selector and press Enter. Use the arrow keys to choose the classic menu under Import Classic Menus and press Enter. Repeat the import and check the distinct menu names. No controls or keyboard handlers are changed by this patch.

Automated validation

  • The final regression file against unchanged source: six expected failures for missing naming/resolution behavior, with four unchanged controls passing. The same test file passes after the fix.

  • npm run test:unit -- packages/block-library/src/navigation --sequence.seed=190023: 19 files and 232 tests pass.

  • npm run test:unit:conventions: passes.

  • Changed-file npm run lint:js: passes.

  • npm run typecheck -- packages/block-library/tsconfig.json: passes.

  • npm run build: passes.

  • After merging trunk on October 24, the Navigation suite, changed-file lint, block-library typecheck, changelog validation and full build pass again. The Entity Fields/Actions API, REST controller and preload subset also passes on native PHP 8.3 (219 tests); this does not substitute for the Linux PHP 7.4 CI job.

  • Native Chromium before the October 24 trunk merge: two actual Navigation dropdown imports in the post editor created distinct saved titles and identical link content through real REST requests. Both retained the existing stored draft / edited publish status behavior. The owned fixtures were deleted and original posts, post metadata, terms, relationships, comments, comment metadata and editor preferences were checked against the final run's snapshot.

The October 24 normal merge includes upstream #85390, which updates the Entity Fields/Actions compatibility layer for the Core API change in Core #14716. The Navigation implementation and its regression tests are unchanged. The same Site Editor crash also appears in the old trunk comparison baseline of a separate performance run; the template-switching E2E failure remains under investigation.

No Docker E2E or full repository test-suite result is claimed.

Maintainer action

Please apply [Type] Bug when reviewing this bug fix. Enforce labels requires exactly one [Type] label; the contributor account has read access and cannot apply it.

Validation after trunk update (2026-11-02)

Merged trunk 66fa56fff04be859c093813a4ef9578f918525f9 normally and validated head 21cf1ec66c8468a6e5dceb63cde47d135b86f339.

Conflict-free normal merge of current trunk66fa56f after the c6 update; no owned source or assertion changes. The initial hosted browser connection-closed log and all prior validation are preserved in phase1.

  • Merged the six newer upstream commits, installed this checkout's own lockfile dependencies, and passed the full production build and full repository typecheck.
  • On Vitest 5.0.5, all 232 Navigation and Navigation Link tests passed in 19 Node/jsdom files, including the ten creation/import regression and control cases.
  • The isolated Chromium Inline Notices fixture passed all 14 cases. The previous hosted browser job had lost its connection while running this unchanged fixture; a full fresh hosted suite is verified separately.
  • Both original Navigation hooks and the creation/import regression fixture remain byte-identical to the preceding published maintenance head.
  • Scoped JavaScript lint, formatting, Vitest conventions, changelog validation, TypeScript configuration and generated API documentation checks passed.
  • Hosted build and test jobs completed successfully on this head.

The earlier native PHP Entity Fields/Actions/controller/preload result (206 tests and 901 assertions) is preserved as historical evidence; it was not rerun for this dependency/UI-only upstream merge.

An extra exploratory browser-only Navigation filter selected no files and failed explicitly; Navigation/Navigation Link coverage is the successful Node/jsdom run above. The dedicated Notices Chromium run selected and passed its real 14 cases.

Chromium output retains the non-fatal upstream PostCSS missing-from warning.

The required type label still needs maintainer action.

Validation update — 9 November 2026

Merged trunk afa2c6a9baec79a4fdfb40ca59adaae410cc5feb and validated published head d4bb4d26f0ead8df14803f52853db263b1f3d8ca. This includes the required trunk baseline.

  • Full JavaScript build and TypeScript checks passed.
  • Related automated tests passed: 232 cases across 19 files (focused-tests).
  • scoped JavaScript lint, package changelog checks, repository conventions, tsconfig validation, and diff whitespace checks passed.

These are local validation results; hosted CI and maintainer-only label requirements remain separate.

Historical branch update — 24 November 2026

Merged upstream trunk 72e50c65901120eadcac90b97940466713fbe37b to resolve the actual conflict. The original source and regression-test contribution is retained. Upstream release sections are preserved, with this PR's notes only in the current Unreleased categories, after upstream notes.

Fresh validation on published head e7d40722a2dc6fa32ff9093fdb8269b7c707324d: own dependency installation, production build, PR changelog validation, full repository typecheck, the scoped lint/static-analysis checks, test conventions, tsconfig validation, generated-documentation checks passed. 10 focused test executions passed across 1 test file.

These are scoped checks, not a full repository or Docker E2E pass. Earlier native-browser/provider evidence remains historical; native browser/site checks were not rerun for this merge. Hosted CI and maintainer-only metadata checks are separate from these local results.

Previous branch update (historical) — 24 November 2026 (current trunk f7aa30a)

Merged upstream trunk f7aa30a92cc1264543a31c1dd649a68eb39ed123 to resolve the actual package-changelog conflict. The original source and regression-test contribution is retained. Upstream release sections are preserved, with this PR's notes only in the current Unreleased categories, after upstream notes.

Fresh validation on published head aa7906c8c074f424eac9890c09b5744f89c2cf7d: own fresh dependency installation, production build, PR changelog validation, full repository typecheck, the scoped lint/static-analysis checks, test conventions, tsconfig validation, generated-documentation checks passed. 10 focused test executions passed across 1 test-file executions.

These are scoped checks, not a full repository or Docker E2E pass. No native WordPress browser/site verification was rerun for this merge; earlier browser/site evidence remains historical. Hosted CI and maintainer-only metadata checks are separate from these local results.

Test isolation follow-up — 24 November 2026

The shuffled CI run caught an extra REST call in the disabled-preview test. A controlled queue probe showed pending saved-menu reads from the earlier import fixture. The fixture now returns a real Response for those reads and awaits their resolution when checking the edited publish status, so that work finishes before the next test resets the shared API mock. Production hooks and the disabled-preview assertions are unchanged.

Fresh validation on 6a00aca68ed78c700ac73a016a91f90362d12e87: the ten regression cases passed with shuffled seeds 199294 and 20261124 and in normal order. Production build, full repository typecheck, scoped lint, test conventions, tsconfig, changelog and generated-documentation checks passed. All applicable upstream pre-commit tasks also passed serially with hooks enabled.

These local runs used Node 24.20 on Windows; the original Node 26/Linux shard was not rerun locally. The controlled probe failed with the earlier synchronous assertion and passed when resolution was awaited. Fresh hosted CI on this head remains separate from these local checks.

Historical branch update — 25 November 2026 (earlier trunk)

Merged upstream trunk 6b90259aefc965729b972fe226d7c22ecc295823 to resolve the actual merge conflicts. The original source and regression-test contribution is retained. Upstream release sections are preserved, with this PR's notes only in the current Unreleased categories, after upstream notes.

Fresh validation on published head 49a481e1c89415d248b9600874bc6c423afb54a5: verified reuse of this checkout’s isolated dependency installation, production build, PR changelog validation, full repository typecheck, the scoped lint/static-analysis checks, test conventions, tsconfig validation, generated-documentation checks passed. 30 focused test executions passed across 3 test-file executions.

These are scoped checks, not a full repository functional-suite or Docker E2E pass. No native WordPress browser/site verification was rerun for this merge; earlier browser/site evidence remains historical. Hosted CI and maintainer-only metadata checks are separate from these local results.

Branch update — 26 November 2026 (startup trunk b173246)

Merged upstream trunk b17324644dd5dffa49fa08c24f1c3523cac3a6a1 to resolve the actual merge conflicts. The original source and regression-test contribution is retained. Upstream release sections are preserved, with this PR's notes only in the current Unreleased categories, after upstream notes.

Fresh validation on published head 0a4c7b41c2f24d8168e53e12e131335c6a4f439a: fresh isolated npm and Composer installation, production build, PR changelog validation, full repository typecheck, the scoped lint/static-analysis checks, test conventions, tsconfig validation, generated-documentation checks passed. 30 focused test executions passed across 3 test-file executions.

These are scoped checks, not a full repository functional-suite or Docker E2E pass. No native WordPress browser/site verification was rerun for this merge; earlier browser/site evidence remains historical. Hosted CI and maintainer-only metadata checks are separate from these local results.

Earlier validation — 27 November 2026 (captured trunk fd1bc1d)

Published head 3a8f4b88dade130283a0c27aa5e89065046e7d44 includes a normal merge of captured trunk fd1bc1d87f2c37abe9a49b3d1ac3084b5b5a1671 to resolve the actual package changelog conflict. Upstream release notes and this PR's original source/test contribution are preserved.

Fresh checks on this merged tree passed: the production build, full repository typecheck, dependency/lockfile lint, documentation generation, whitespace checks, scoped JavaScript lint, test conventions, TypeScript configuration lint. The same 10-case Navigation hook suite passed in three planned test orderings (30 test executions, with overlap). The checkout's own dependencies were freshly installed and their inputs and workspace links verified.

The scoped changelog checks passed. The scoped published-dependency checks passed using the documented Windows junction adapter; these do not constitute the default full audit.

This merge-only commit used HUSKY=0 after the separate current-tree checks; earlier source-hook results retain their original heads. No fresh native WordPress browser verification or Docker E2E run is claimed. Hosted CI for this new head is separate from the local results.

Current validation — 28 November 2026

Published head 927c6561a0fd0cc601acc840d76f602228e62b36 includes a normal merge of captured trunk 48c4df2d3c1323c0cffeed9f85702df7187f9d43 to resolve the package changelog conflicts. The original production contribution is retained exactly relative to the new base. The Navigation unit-test setup now marks the current getEntityConfig resolution for ['postType', ''] complete after providing its fixture entities. This prevents an unrelated /types?context=view bootstrap request from blocking the deliberately delayed menu requests or polluting their request counts; the existing assertions are unchanged. Upstream release text is preserved, and this PR's entries follow upstream entries under Unreleased.

This checkout's own npm and Composer dependencies were installed for the current inputs. The production build and full repository typecheck passed. Passing checks also include scoped source lint and documentation generation.

The selected JavaScript/Browser Mode groups passed 30 test executions across 3 file executions; overlapping groups are counted as executions.

Scoped published-dependency checks with the Windows junction adapter reported zero findings. These are separate scoped results; the default full audit was not run.

This normal merge commit used HUSKY=0 after the separate current-tree checks. Codex performed this maintenance and automated verification. Hosted CI and maintainer-only metadata requirements are tracked separately.

Earlier native-browser evidence retains its original head and scope. No fresh native WordPress browser run is claimed for this update.

These are scoped functional checks; no full repository functional-suite or Docker E2E pass is claimed.

Use of AI Tools

Codex also performed the branch maintenance and automated validation dated above.

OpenAI Codex selected and investigated the issue, authored the implementation and tests, ran automated validation and prepared this PR. A separate Codex agent reviewed the patch. The repository owner has not performed a human code review; maintainer review is still required.

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

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 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: salvatorecorsi <salvatorecorsi@git.wordpress.org>
Co-authored-by: kathrynwp <zoonini@git.wordpress.org>
Co-authored-by: getdave <get_dave@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.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@salvatorecorsi
salvatorecorsi marked this pull request as ready for review October 23, 2026 07:41
@salvatorecorsi

salvatorecorsi commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Could a maintainer rerun the current iOS job once? On 0a4c7b41, Git checkout fails with an HTTP/2 stream cancellation and an incomplete pack, before any simulator tests run. This is a different failure from the older selection assertion. I can't rerun upstream jobs with the fork's permissions.

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 library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force unique names for imported classic menus in Nav block

1 participant