Skip to content

Admin UI: Configure router Link to match exact to fix duplicate aria-current in breadcrumbs - #87050

Draft
aduth wants to merge 10 commits into
trunkfrom
fix/aria-current-routing
Draft

aduth wants to merge 10 commits into
trunkfrom
fix/aria-current-routing

Conversation

@aduth

@aduth aduth commented Nov 18, 2026

Copy link
Copy Markdown
Member

What?

Updates @wordpress/route's Link component implementation to wrap TanStack Router's default implementation and specify activeOptions.exact as true.

Why?

By default, TanStack considers a link "active" if its to partially matches the current page. This is problematic for nested navigations, and especially for breadcrumb navigations, where the breadcrumb chain is often increasing specificity.

For example:

<Link to="/settings">Settings</Link> › <Link to="/settings/privacy">Privacy</Link>

In this example, both the Settings link and Privacy link will apply aria-current="page" when the current URL is /settings/privacy, which is contrary to APG Breadcrumbs pattern guidance "The link to the current page has aria-current set to page."

Personally I don't know that this should be the default behavior, and have followed-up on an issue describing this behavior which was closed in 2024.

This behavior was also flagged previously in #79746 (comment).

How?

Updates @wordpress/route's Link to wrap the default TanStack Router Link component and merges activeOptions.exact: true as the default unless specifically overridden.

Testing Instructions

  1. Go to Storybook, either clicking "Preview: Storybook" button in the PR Meta comment under this pull request, or running npm run storybook:dev locally
  2. Go to the "Design System > Admin UI > With Router Navigation" story
  3. Click "Privacy" navigation item
  4. Inspect the "Overview" and "Privacy" links in the navigation
  5. Observe that only "Privacy" has aria-current="page"

Use of AI Tools

Researched and implemented in coordination with Claude Code + Opus 5.5.

@aduth
aduth requested review from a team and youknowriad November 18, 2026 22:11
@aduth
aduth requested a review from manzoorwanijk as a code owner November 18, 2026 22:11
Copilot AI balanced review requested due to automatic review settings November 18, 2026 22:11
@github-actions

github-actions Bot commented Nov 18, 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: aduth <aduth@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@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: 0 B

Total Size: 8.71 MB

03f0d5c Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric a840574 trunk % Change
timeToFirstByte 59.1 ms +2.79% -2.37% 57.35 ms +7.85% -1.92% 3.05%
largestContentfulPaint 92 ms +4.35% -4.35% 92 ms +4.35% -4.35% 0%
lcpMinusTtfb 30.65 ms +20.88% -4.57% 32.55 ms +18.89% -11.21% -5.84%
wpBeforeTemplate 30.29 ms +8.81% -3.6% 29.85 ms +12.33% -2.11% 1.47%
wpTemplate 24.17 ms +2.77% -2.4% 23.24 ms +4.04% -4.39% 4%
wpTotal 54.99 ms +2.95% -2.8% 53.31 ms +8.44% -1.89% 3.15%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.47%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric a840574 trunk % Change
timeToFirstByte 50.05 ms +5.59% -3.5% 48.2 ms +5.91% -3.01% 3.84%
largestContentfulPaint 88 ms +4.55% -4.55% 82 ms +7.32% -2.44% 7.32%
lcpMinusTtfb 37.2 ms +2.15% -3.23% 34.7 ms +4.61% -4.18% 7.2%
wpBeforeTemplate 27.96 ms +7.62% -1.36% 26.96 ms +7.53% -2.19% 3.71%
wpTemplate 17.58 ms +8.02% -2.62% 17.53 ms +6.1% -5.31% 0.29%
wpTotal 46.66 ms +5.83% -3.26% 44.96 ms +5.32% -2.96% 3.78%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.58%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric a840574 trunk % Change
mediaProcessingJpeg 405.96 ms +1.07% -0.55% 400.35 ms +1.46% -0.47% 1.4%
mediaProcessingAvif 6192.31 ms +0.09% -0.2% 6134.07 ms +0.27% -0.04% 0.95%
mediaProcessingJpegToAvif 4312.76 ms +1.01% -0.57% 4240.81 ms +0.53% -0.48% 1.7%

media-upload

Metric a840574 trunk % Change
jpegUploadProcessing 2019.13 ms +2.13% -23.29% 1954.81 ms +1.44% -21.23% 3.29%
pngUploadProcessing 278.92 ms +2.86% -4.27% 281.09 ms +2.22% -3.82% -0.77%
largeJpegUploadProcessing 1966.99 ms +1.6% -22.4% 1732.5 ms +14.29% -13.12% 13.53%
multipleImageUploadProcessing 2129.21 ms +0.94% -0.81% 2098.18 ms +0.57% -2.31% 1.48%

post-editor

Metric a840574 trunk % Change
serverResponse 484.86 ms +2.44% -7.92% 471.46 ms +5.35% -6.45% 2.84%
firstPaint 448.12 ms +2.49% -5.2% 416.49 ms +2.08% -4.17% 7.59%
domContentLoaded 836.53 ms +1.46% -2.73% 835.41 ms +1.17% -2.42% 0.13%
loaded 837.75 ms +1.46% -2.77% 836.4 ms +1.2% -2.39% 0.16%
firstContentfulPaint 472.04 ms +3.11% -4.71% 468.13 ms +1.38% -1.43% 0.84%
firstBlock 2264.94 ms +0.87% -1.61% 2227.61 ms +2.94% -0.61% 1.68%
type 17.34 ms +14.99% -7.38% 17.73 ms +7.78% -10.04% -2.2%
typeWithoutInspector 17.76 ms +2.31% -12.05% 20.82 ms +11.67% -14.27% -14.7%
typeWithTopToolbar 21.65 ms +4.76% -3.28% 23.38 ms +7.78% -6.63% -7.4%
typeContainer 8.32 ms +9.37% -11.78% 8.49 ms +16.14% -7.18% -2%
focus 111.07 ms +7.68% -2.23% 109.74 ms +3.74% -1.67% 1.21%
firstFocus 277.66 ms +0% -0% 290.59 ms +0% -0% -4.45%
selectAll 391.67 ms +12.8% -1.55% 433.96 ms +0.5% -1.05% -9.75%
undo 28.96 ms +5.7% -4.94% 28.76 ms +5.04% -4.59% 0.7%
listViewOpen 41.38 ms +9.64% -7.32% 66.13 ms +10.48% -10.98% -37.43%
inserterOpen 42.04 ms +7.25% -13.04% 47.2 ms +8.75% -8.05% -10.93%
inserterHover 11.45 ms +12.4% -7.6% 12.21 ms +6.8% -14.09% -6.22%
inserterSearch 8.1 ms +13.95% -7.9% 8.75 ms +4.34% -4.34% -7.43%
loadPatterns 649.16 ms +4.76% -4.6% 672.56 ms +4.89% -2.41% -3.48%
wpTotal 475.18 ms +2.45% -8.23% 461.87 ms +5.38% -6.6% 2.88%
wpMemoryUsage 14.81 MB +0% -0% 14.77 MB +0% -0% 0.26%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric a840574 trunk % Change
serverResponse 403.67 ms +0.83% -6.35% 399.93 ms +2.14% -6.04% 0.94%
firstPaint 435.96 ms +6.62% -6.67% 411.28 ms +11.26% -8.43% 6%
domContentLoaded 820.52 ms +4.73% -0.92% 824.91 ms +1.96% -1.23% -0.53%
loaded 821.72 ms +4.7% -0.94% 825.99 ms +1.93% -1.21% -0.52%
firstContentfulPaint 446.77 ms +10.38% -1.11% 459.57 ms +1.48% -1.01% -2.79%
firstBlock 2470.46 ms +2.38% -0.8% 2452.66 ms +0.58% -1.42% 0.73%
type 17.66 ms +11.61% -14.04% 17.82 ms +4.32% -8.02% -0.9%
navigate 120.54 ms +3.77% -2.52% 111.53 ms +11.15% -3.72% 8.08%
loadPatterns 1396.26 ms +1.17% -3.7% 1415.24 ms +4.07% -4.37% -1.34%
loadPages 936.73 ms +2.25% -1.45% 938.44 ms +2.17% -1.12% -0.18%
wpTotal 394.54 ms +0.91% -6.49% 390.81 ms +2.21% -6.26% 0.95%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.3%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

03f0d5c 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.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4

03f0d5c Run

@github-actions github-actions Bot added the [Package] Admin UI /packages/admin-ui label Nov 18, 2026
@aduth aduth added the [Type] Bug An existing feature does not function as intended label Nov 18, 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.

🟢 Approval recommended

No active review issues block approval of the Link exact-match default change.

No open issues 🎉

What changed in this PR

Updates @wordpress/route’s Link to use exact-path matching by default, preventing parent links from also receiving aria-current="page" in breadcrumbs and nested navigation.

Changes:

  • Wraps TanStack Router’s Link with an overridable exact-match default.
  • Adds regression tests, a router-backed navigation story, and documentation.
  • Updates dependencies and TypeScript references, and exempts development files from bundled-package private API import restrictions.
File Description
tools/​eslint/​suppressions.json Removes the obsolete router-story suppression.
tools/​eslint/​config.mjs Exempts development files from private API import restrictions.
packages/​route/​tsconfig.json Adds the element development-project reference.
packages/​route/​tsconfig.build.json Adds the element build-project reference.
packages/​route/​src/​test/​link.jsdom.test.tsx Tests exact matching and explicit partial matching.
packages/​route/​src/​link.tsx Implements the exact-match default while forwarding refs and props.
packages/​route/​src/​index.ts Exports the wrapped Link.
packages/​route/​README.md Documents the default matching behavior.
packages/​route/​package.json Adds element and testing dependencies.
packages/​route/​CHANGELOG.md Records the breaking default change and override option.
packages/​admin-ui/​src/​stories/​with-router.tsx Supports a configurable initial route in stories.
packages/​admin-ui/​src/​page/​stories/​index.story.tsx Adds a nested router-navigation example.
package-lock.json Records the updated dependencies.

Review effort: Balanced

@ciampo ciampo 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.

Alternatively, could / should we handle this in Admin UI? Breadcrumbs already knows the last item is current, and Page navigation gets currentHref. An Admin UI adapter could use useLinkProps for client-side navigation, then apply its own aria-current after spreading the router props onto the anchor. That gives each navigation control over which link it marks as current and preserves the shared Link matching behavior.

Just a thought, I guess it depends on the type of fix we want to make

Comment thread packages/route/src/link.tsx Outdated
ref={ ref }
// An active link gets `aria-current="page"`, which must not be on
// links to parent pages.
activeOptions={ { exact: true, ...activeOptions } }

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.

At /settings/privacy?filter=active, the link to /settings/privacy loses aria-current="page" because exact also requires the search parameters to match. Could we keep the shared default and opt into exact pathname matching where the navigation treats query parameters as page state?

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.

At /settings/privacy?filter=active, the link to /settings/privacy loses aria-current="page" because exact also requires the search parameters to match. Could we keep the shared default and opt into exact pathname matching where the navigation treats query parameters as page state?

It's good to highlight the query parameter aspect. I had not considered it. Though I don't know that it would change how I feel about the default here. Sure, query parameters can be added for all kinds of reasons, but one of those reasons could well be to distinguish the active page. If we matched only on pathname, it would add the ability to distinguish active pages on query parameters (as well as being additional complexity). Being exact still feels like the better default, all things considered.

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.

Breadcrumbs also supports a link as its last item. I tried a linked Privacy breadcrumb at /settings/privacy?filter=active and neither link had aria-current="page". Could we set it explicitly on the linked last item and add a test for that case? That would let the shared Link keep exact matching.

Comment thread packages/route/CHANGELOG.md Outdated

### Breaking Changes

- `Link` is active only when the current path matches its `to` path exactly, so it no longer adds `aria-current="page"` on subpages. Pass `activeOptions` to change this.

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.

Missing PR link

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.

@copilot can you add the link

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.

Added the PR #87050 link to the changelog entry in commit e3a02b98.

@aduth

aduth commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Alternatively, could / should we handle this in Admin UI? Breadcrumbs already knows the last item is current, and Page navigation gets currentHref. An Admin UI adapter could use useLinkProps for client-side navigation, then apply its own aria-current after spreading the router props onto the anchor. That gives each navigation control over which link it marks as current and preserves the shared Link matching behavior.

I'll look at this again today, but my impression is that the Link default in TanStack is flawed, and so for us to work around this, it makes sense that it should apply at our Link abstraction.

@aduth
aduth force-pushed the fix/aria-current-routing branch from e3a02b9 to 94d1be4 Compare November 19, 2026 21:40
@aduth

aduth commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Alternatively, could / should we handle this in Admin UI? Breadcrumbs already knows the last item is current, and Page navigation gets currentHref. An Admin UI adapter could use useLinkProps for client-side navigation, then apply its own aria-current after spreading the router props onto the anchor. That gives each navigation control over which link it marks as current and preserves the shared Link matching behavior.

So I think we want both the updated default in Link, as well as some handling in Admin UI.

  • We want Navigation to assign aria-current even if that's already what Link will be doing, because Navigation is designed to support being used outside a TanStack Router environment (per Admin UI: Decouple Page component from @wordpress/route #77040), so we need it to assign aria-current when the link is a plain <a />. In fact, it's handling of aria-current in considering currentHref has been right all along to differentiate "current href", and it's just that TanStack Link has been adding the aria-current wrongly to ancestor pages as well.
  • Breadcrumbs shouldn't need to know about it? At least not in what's relevant for assigning aria-current. For breadcrumbs, there is no aria-current because the current page is the heading, not a link.

And as mentioned above, we still want the defaults changed in Link because exactness is the better default.

That being said, some of the documentation added here only referenced "pathname" in evaluating exactness, so I updated this in 94d1be4 to also include querystring.

@aduth

aduth commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

I should say that my feelings about overriding the default are a "strong opinion loosely held".

It does appear that it's not quite as accidental as I might have initially thought. They are quite explicit about all this in their documentation around active options, and they show an example of needing exact: true for a homepage / root route, which is not too much unlike the hierarchical navigation we're considering in many of our use-cases.

By default, it will check if the resulting pathname is a prefix of the current route.

But there's still some problems with this:

Comment thread tools/eslint/config.mjs Resolved
@ciampo

ciampo commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

I’m ok with exact matching as the default for Link. Your point that query parameters can “distinguish the active page” makes sense. I’d keep Navigation using currentHref too, since it also supports plain anchors.

For breadcrumbs, there is no aria-current because the current page is the heading, not a link.

There’s one case here: Breadcrumbs renders the last item as a link when it has a to. With Privacy linking to /settings/privacy, adding ?filter=active leaves neither Settings nor Privacy marked as current. Since Breadcrumbs already knows which item is current, could we set aria-current="page" on the linked last item ?

@aduth

aduth commented Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

For Breadcrumbs, you're right that the last item can be a link, and I guess my next question would be: Do we want that? It's valid (APG Breadcrumb pattern uses it), but our own examples don't use it. We could decide to standardize around the last item always being a static text and not a link. And in fact, my own #86982 goes so far as to codify that fact, making the last item always rendered as a heading.

So the question is: Should we support links on the last item of a breadcrumb?

I think our own Breadcrumb usage guidelines suggest the latter: "The current item is not a link and defaults to aria-current="page".". Although it's an interesting point that we could still be adding aria-current="page" to the static text heading. The APG pattern describes this as optional, and I'm not sure what kind of practical effect that would have.

@ciampo ciampo 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.

Good reflection.

I'd go with a heading for the last item. That's what our routes already render. If #86982 lands first, that covers my concern here. If this ships first, could we keep the linked final item marked as current while we still support it?

render( <RouterProvider router={ router } /> );
}

describe( 'Link', () => {

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.

Nit: Could we add a case with two links to the same path, one with search={ { filter: 'active' } } and one without? At ?filter=active, only the filtered link should have aria-current="page".

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.

Nit: Could we add a case with two links to the same path, one with search={ { filter: 'active' } } and one without? At ?filter=active, only the filtered link should have aria-current="page".

Good idea 👍 Added in 143400c.

@aduth
aduth force-pushed the fix/aria-current-routing branch from 81c9679 to 143400c Compare November 20, 2026 21:13
@aduth

aduth commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

If this ships first, could we keep the linked final item marked as current while we still support it?

Yeah, that makes sense. I added this in 9e5b731 to reflect the current reality and we can revisit if/when we change direction as in #86982.

@ciampo ciampo 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.

LGTM 🚀

Comment thread tools/eslint/suppressions.json Outdated
},
"packages/admin-ui/src/stories/with-router.tsx": {
"no-restricted-imports": {
"packages/block-directory/src/components/auto-block-uninstaller/index.js": {

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.

Could we drop the change to tools/eslint/suppressions.json? It only swaps two entries, and CI puts them back in their original order.

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.

Thanks, this was the result of a bad rebase where I manually resolved the conflicts. I'll fix it up.

@aduth
aduth force-pushed the fix/aria-current-routing branch from 143400c to 4be0668 Compare November 23, 2026 20:15
@aduth

aduth commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

I'm starting to second-guess myself on the approach here. I think we want the same end-result as far as aria-current applying to only the actual current page, along with the Breadcrumbs improvements.

But I'm thinking maybe we should avoid the breaking change to Link for now, at least until TanStack/router#8979 settles. We're quite explicit that @wordpress/route inherits from TanStack Router, so I think it could be best to follow the expected defaults, warts and all. A worst-case scenario here is that we change the default, get some feedback around TanStack/router#8979 that suggests that the current default is actually the ideal behavior, and then at some point have to revert our changed default, or continue to maintain a divergence that adds additional cognitive overload to how people think of the abstraction.

The more conservative option is to keep Link as it is and update each of our individual affected call-sites to use activeOptions.exact: true explicitly. It's a smaller, safer change, and we can revisit the default later, ideally in combination with whatever upstream changes might come from the related issue.

@aduth

aduth commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

The more conservative option is to keep Link as it is and update each of our individual affected call-sites to use activeOptions.exact: true explicitly. It's a smaller, safer change, and we can revisit the default later, ideally in combination with whatever upstream changes might come from the related issue.

This proliferates a little bit with #86982, since the routing concerns are pushed into each route's RouterLink implementation.

Which touches on the problem of what each route should be responsible for. #86982 already pushes responsibility of wiring links to the router to each route, and with my revised proposal here we'd also be pushing expectations around how each page controls its links by passing activeOptions (since @wordpress/admin-ui wouldn't know that a Link is a TanStack link). #77040 mentions a possibility of a "context provider" and I think it would conceptually make a lot of sense that @wordpress/boot could define the default Link behavior for Pages within, but the practical realities of bundled scripts and multiple copies of @wordpress/admin-ui make this challenging.

I still think it's the better option for now, and not a blocker. Separately we should look into ways to better share this default behavior.

@aduth

aduth commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

The changes after 03f0d5c are certainly simpler, but it's made it clearer that the problem is more to do with wiring Page's components props and moving Page to be decoupled from routing. The "fix" here is now localized to Breadcrumbs since it's still wired up to @wordpress/route, but #86982 will basically undo that. And it's a pretty bad sign if we're trying to fix something by leaning on this wiring, if we're not even doing the "wiring-up" ourselves yet in the current routes, nor in many of the consumer examples we've seen (e.g. woocommerce/woocommerce#70330). We're basically taking away something that "just worked" (i.e. @wordpress/admin-ui follows @wordpress/route routing) without a clear alternative in place. And I don't really want to push this responsibility onto consumers to handle when they didn't have to previously. #77040 is well-intentioned, but I don't want to make the primary use-case more difficult in the process.

I think we really have to bite the bullet and find a solution to the React context problem with duplicate packages, which might mean some shared global value that can be future-compatible. If we had a solution there, we could ensure that @wordpress/boot pages still inherit the same routing default behavior as they do today.

@ciampo ciampo 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.

The more conservative option is to keep Link as it is and update each of our individual affected call-sites to use activeOptions.exact: true explicitly.

I'd keep the Breadcrumbs fix here and leave the shared Link default alone. It's low risk either way. None of our routes hit the bug today, since no parent crumb is a path prefix of its page.

We're basically taking away something that "just worked" (i.e. @wordpress/admin-ui follows @wordpress/route routing) without a clear alternative in place.

I think this concern belongs to #86982 more than to this PR. There, a Boot page that doesn't pass components.link renders a plain anchor like <a href="/settings">, which leaves wp-admin because Boot keeps the route in ?p=. The copied adapters also mark the parent crumb as current on nested paths. In the Settings fixture at /settings/general, the Settings link gets aria-current="page".

I think we really have to bite the bullet and find a solution to the React context problem with duplicate packages, which might mean some shared global value that can be future-compatible.

Boot and each route do inline their own Admin UI, but they share one @wordpress/route module. Could the link context live in a script module too? @wordpress/widget-primitives already does that for the dashboard's links. That might save us a new global.

One note on this PR itself. The description still covers the @wordpress/route change. The testing steps also pass without the Breadcrumbs fix, because the story's adapter sets activeOptions itself. Could we point them at a nested breadcrumb instead? None of our routes show the bug, but the ThreeLevels story would with initialPath: '/settings/connectors/example'. Both parent links are current there on trunk, and neither should be with this change.

Comment on lines +11 to +22
Link: ( ( {
to,
activeOptions,
children,
...props
}: ComponentProps< 'a' > & {
to: string;
activeOptions?: unknown;
} ) => (
<a href={ to } { ...props }>
{ children }
</a>

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.

Could we render Settings and Privacy with a memory router at /settings/privacy?filter=active and assert that only Privacy is current? The mock drops activeOptions, so this test still passes if we remove the fix from the parent link.

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] Admin UI /packages/admin-ui [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants