Skip to content

Navigation: Show the stored link while a bound entity loads - #84006

Draft
jeryj wants to merge 1 commit into
trunkfrom
fix/navigation-link-pending-binding-url
Draft

jeryj wants to merge 1 commit into
trunkfrom
fix/navigation-link-pending-binding-url

Conversation

@jeryj

@jeryj jeryj commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What?

Follow up to #83408.

Keeps the Link UI showing the selected link while the record for a newly bound entity is still loading, instead of briefly treating the link as empty.

Why?

Since #83408, a navigation link can be pointed at an entity of another type, for example a page link changed to a category. The URL is bound to the entity (core/term-data or core/post-data), and the binding has no URL until that entity's record loads. Pages are usually already in the store, but categories, tags and other types are not, so after selecting one the Link UI briefly:

  • showed the "No link selected" badge,
  • brought back the "Create page" and "Add block" tools,
  • swapped the title for the page's HTML title from the rich preview (for example "Uncategorized – Site name").

It then corrected itself once the record request finished, so the wrong state lasts as long as that request.

How?

  • useEntityBinding returns a new isBoundEntityPending flag, true while hasFinishedResolution( 'getEntityRecord', … ) is false for the bound record. This tells a loading record apart from a deleted one, so a deleted entity still shows as missing.
  • While the record is pending, the navigation Link UI uses the URL stored on the block (getBlockAttributes( clientId ).url) and the link label as the entity title. Once the record loads, the bound value takes over as before.
  • LinkControl's entityUrlFallbackRef / previewValue workaround, which only covered taxonomy links, is removed. Its TODO asked for removal once the binding returns a URL while resolving, which the Link UI now provides.

The inspector sidebar's "Link to" preview also uses useLinkPreview with the bound URL and may show the same brief state. It is not changed or tested here.

Testing Instructions

  1. Open a post and insert a Navigation block with at least one link.
  2. In the browser dev tools, throttle the network (for example "Slow 4G") so the gap is easy to see.
  3. Click the "Add page" appender in the Navigation block.
  4. Search for "Uncategorized" and select the category result.
  5. While the category loads, the preview should show "Uncategorized" with the category URL. It should not show "No link selected", "Create page" or "Add block", and the title should not change to the page's HTML title.
  6. Once loaded, the "Category" badge appears.
  7. Repeat on trunk to see the in-between state.

Automated coverage:

  • New e2e test in navigation.spec.js holds the category request open and checks the preview during and after the wait. It fails on trunk and passes here.
  • New unit tests for isBoundEntityPending in use-entity-binding.jsdom.test.js: loading, loaded, deleted, no binding, and the tag → post_tag mapping.

Testing Instructions for Keyboard

  1. Insert a Navigation block, then press Tab until the "Add page" appender has focus, and press Enter.
  2. Type "Uncategorized", press the Down arrow until the category result is highlighted, and press Enter.
  3. Confirm the preview shows the category link with no "No link selected" badge while it loads, and that focus stays in the link popover.

Use of AI Tools

This PR was written with Claude Code (Claude Opus 5.5): debugging the in-between state with a diagnostic e2e trace, writing the tests and the fix. I reviewed the changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_013RXB2AJtSuC5Gdi1ZUy8wf

When a navigation link switches to an entity type whose record isn't loaded yet (for example, a page link changed to a category), the URL binding returns no URL until the record request finishes. The Link UI treated the link as empty in the meantime: it showed "No link selected", brought back the "Create page" and "Add block" tools, and swapped the title for the page's HTML title from the rich preview.

`useEntityBinding` now reports `isBoundEntityPending` from the record's resolution state, which tells a loading record apart from a deleted one. While it is pending, the Link UI uses the URL stored on the block and the link label as the entity title. This makes the taxonomy-only URL fallback in LinkControl unnecessary, so it is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013RXB2AJtSuC5Gdi1ZUy8wf
@jeryj jeryj added [Block] Navigation Affects the Navigation Block [Type] Bug An existing feature does not function as intended labels Oct 1, 2026
@github-actions github-actions Bot added [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: -29 B (0%)

Total Size: 8.25 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 515 kB -103 B (-0.02%)
build/scripts/block-library/index.min.js 366 kB +74 B (+0.02%)

09d4cd8 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 3dda9a0 trunk % Change
timeToFirstByte 58.9 ms +11.97% -4.16% 57.1 ms +11.12% -2.28% 3.15%
largestContentfulPaint 100 ms +4% -6% 92 ms +8.7% -4.35% 8.7%
lcpMinusTtfb 37.25 ms +17.58% -4.7% 32.85 ms +7.61% -1.98% 13.39%
wpBeforeTemplate 28.87 ms +21.93% -1.66% 28.75 ms +14.43% -2.16% 0.42%
wpTemplate 24.74 ms +2.34% -2.71% 24.63 ms +3.78% -2.76% 0.45%
wpTotal 55.15 ms +10.48% -4.01% 53.5 ms +10.84% -2.21% 3.08%
wpMemoryUsage 7.62 MB +0% -0% 7.59 MB +0% -0% 0.46%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 3dda9a0 trunk % Change
timeToFirstByte 47.45 ms +4% -0.32% 48.75 ms +4.62% -1.13% -2.67%
largestContentfulPaint 104 ms +3.85% -3.85% 104 ms +0% -1.92% 0%
lcpMinusTtfb 55.75 ms +2.24% -5.11% 53.75 ms +2.79% -3.07% 3.72%
wpBeforeTemplate 26.73 ms +0.94% -2.02% 27.14 ms +10.8% -1.51% -1.51%
wpTemplate 18.02 ms +2% -1.78% 18.1 ms +1.44% -1.99% -0.44%
wpTotal 44.51 ms +4.38% -0.45% 45.6 ms +5.37% -1.38% -2.39%
wpMemoryUsage 6.25 MB +0% -0% 6.20 MB +0% -0% 0.71%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric 3dda9a0 trunk % Change
mediaProcessingJpeg 403.38 ms +0.4% -0.81% 400.09 ms +0.36% -1.3% 0.82%
mediaProcessingAvif 6060.31 ms +0.25% -0.13% 6068.36 ms +0.1% -0.06% -0.13%
mediaProcessingJpegToAvif 4171.81 ms +0.12% -0.02% 4202.33 ms +0.04% -0.08% -0.73%

media-upload

Metric 3dda9a0 trunk % Change
jpegUploadProcessing 1448.21 ms +33.08% -1.28% 1417.68 ms +1.67% -0.2% 2.15%
pngUploadProcessing 170.96 ms +3.23% -2.25% 205.95 ms +10.57% -15.55% -16.99%
largeJpegUploadProcessing 1402 ms +0.52% -0.49% 1413.62 ms +0.48% -0.77% -0.82%
multipleImageUploadProcessing 1561.53 ms +1.49% -0.45% 1568.8 ms +1.43% -2.03% -0.46%

post-editor

Metric 3dda9a0 trunk % Change
serverResponse 523.73 ms +6.48% -8.53% 506.54 ms +9.02% -2.71% 3.39%
firstPaint 230.82 ms +9.38% -16.03% 211.14 ms +9.62% -1.77% 9.32%
domContentLoaded 1134.93 ms +4.24% -1.17% 1126.51 ms +2.3% -1.04% 0.75%
loaded 1136.38 ms +4.22% -1.17% 1128.05 ms +2.3% -1.06% 0.74%
firstContentfulPaint 471.8 ms +3.79% -2.7% 466 ms +1.18% -2.08% 1.24%
firstBlock 3440.05 ms +0.81% -1.63% 3344.39 ms +0.37% -0.15% 2.86%
type 19.56 ms +2.56% -4.04% 19.02 ms +6.05% -7.41% 2.84%
typeWithoutInspector 18.77 ms +5.01% -2.24% 18.37 ms +13.83% -3.43% 2.18%
typeWithTopToolbar 24.46 ms +11.77% -1.35% 21.72 ms +7.04% -6.03% 12.62%
typeContainer 8.9 ms +6.29% -10.11% 8.72 ms +4.59% -5.05% 2.06%
focus 76.42 ms +19.35% -3.79% 74.08 ms +7.82% -5.14% 3.16%
firstFocus 214.94 ms +0% -0% 196.16 ms +0% -0% 9.57%
selectAll 573.23 ms +0.44% -7% 531.02 ms +3.89% -7.14% 7.95%
listViewOpen 66.91 ms +10.46% -9.49% 63.37 ms +8.79% -3.14% 5.59%
inserterOpen 25.14 ms +1.83% -11.89% 21.02 ms +17.41% -7.9% 19.6%
inserterHover 2.31 ms +5.63% -12.12% 2.13 ms +20.66% -6.1% 8.45%
inserterSearch 7.97 ms +6.65% -5.02% 8.06 ms +9.55% -9.06% -1.12%
loadPatterns 666.22 ms +1.47% -0.55% 656.76 ms +5.5% -3.71% 1.44%
wpTotal 513.69 ms +6.6% -8.6% 496.46 ms +9.15% -2.81% 3.47%
wpMemoryUsage 13.17 MB +0% -0% 13.13 MB +0% -0% 0.28%
wpDbQueries 54 +0% -1.85% 54 +0% -1.85% 0%

site-editor

Metric 3dda9a0 trunk % Change
serverResponse 245.37 ms +2.67% -4.61% 245.93 ms +2.1% -5.28% -0.23%
firstPaint 151.34 ms +7.65% -6.58% 156.58 ms +16.39% -15.14% -3.35%
domContentLoaded 690.6 ms +1.4% -2.03% 685.12 ms +2.56% -2.06% 0.8%
loaded 691.71 ms +1.37% -2.06% 685.93 ms +2.58% -2.07% 0.84%
firstContentfulPaint 294.35 ms +0.94% -1.84% 297.04 ms +6.82% -1.86% -0.91%
firstBlock 2415.65 ms +3.08% -0.51% 2418.06 ms +0.66% -1.41% -0.1%
type 12.81 ms +3.36% -6.32% 13.94 ms +7.89% -7.03% -8.11%
navigate 80.29 ms +3.95% -8.79% 79.64 ms +4.22% -2.89% 0.82%
loadPatterns 866.36 ms +2.45% -4.89% 964.04 ms +5.21% -6.25% -10.13%
loadPages 1063.99 ms +0.79% -11.27% 1047.61 ms +0.71% -7.29% 1.56%
wpTotal 239.18 ms +2.74% -4.93% 239.6 ms +2.09% -6.81% -0.18%
wpMemoryUsage 12.14 MB +0% -0% 12.10 MB +0% -0% 0.4%
wpDbQueries 44 +0% -2.27% 44 +0% -0% 0%

09d4cd8 Run

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 [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant