Repository navigation
fix(ui): strip query params from tab href before active-state matching - #33047
Merged
Merged
Conversation
Tab matchStrategy ('exact' and 'prefix') compared the raw tab href
against location.pathname, which never includes query params. This
meant tabs with query params in their href could never be matched
as active.
Extract an hrefPathname helper that strips query params and hash
fragments, and use it in both isTabActive and the segment count
computation.
Signed-off-by: Johan Persson <[email protected]>
Story description text was rendering inline without line breaks between elements. Add as="p" to Text components so each renders as a block-level paragraph. Signed-off-by: Johan Persson <[email protected]>
Contributor
Changed Packages
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug in the Tabs component where tab active-state matching failed for tabs with query parameters in their href attribute. The fix extracts a pathname from the href by stripping query params and hash fragments before matching against location.pathname.
Changes:
- Added
hrefPathnamehelper function to strip query params and hash from tab hrefs - Updated tab matching logic to compare only pathname portions
- Added Storybook story demonstrating the fix with query parameters
- Fixed inline text rendering in existing Storybook stories (changed Text components to use
as="p")
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/ui/src/components/Tabs/Tabs.tsx | Added hrefPathname helper and updated matching logic to strip query params/hash from hrefs |
| packages/ui/src/components/Tabs/Tabs.stories.tsx | Added new story for query param scenario and fixed Text component rendering |
| .changeset/fix-tab-match-query-params.md | Documented the bug fix for tabs with query parameters |
Contributor
🎨 Visual Testing with Chromatic
|
Naycon
enabled auto-merge (rebase)
February 27, 2026 10:56
cdedreuille
approved these changes
Mar 2, 2026
Contributor
|
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, I just made a Pull Request!
Tab
matchStrategy(exactandprefix) compared the raw tabhrefagainstlocation.pathname, which never includes query parameters. This meant tabs with query params in their href (e.g.,/page?group=foo) could never show as active.This extracts an
hrefPathnamehelper that strips query params and hash fragments before matching, so only the pathname portion is compared. Also adds a Storybook story demonstrating the fix and fixes inline rendering of description text in existing stories.✔️ Checklist
Signed-off-byline in the message.