Skip to content

fix(ui): strip query params from tab href before active-state matching - #33047

Merged
Naycon merged 2 commits into
masterfrom
bui-tab-match-strategy-ignore-query-params
Mar 2, 2026
Merged

Naycon merged 2 commits into
masterfrom
bui-tab-match-strategy-ignore-query-params

Conversation

@Naycon

@Naycon Naycon commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Hey, I just made a Pull Request!

Tab matchStrategy (exact and prefix) compared the raw tab href against location.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 hrefPathname helper 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

  • A changeset describing the change and affected packages.
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message.

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]>
Copilot AI review requested due to automatic review settings February 27, 2026 10:00
@Naycon
Naycon requested a review from a team as a code owner February 27, 2026 10:00
@backstage-goalie

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/ui packages/ui patch v0.12.1-next.0

@backstage-goalie backstage-goalie Bot added size:medium Medium-sized pull requests receive no change in priority for reviews. waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Feb 27, 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.

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 hrefPathname helper 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

@github-actions

Copy link
Copy Markdown
Contributor

🎨 Visual Testing with Chromatic

@Naycon
Naycon enabled auto-merge (rebase) February 27, 2026 10:56
@Naycon
Naycon merged commit a0e4d38 into master Mar 2, 2026
31 checks passed
@Naycon
Naycon deleted the bui-tab-match-strategy-ignore-query-params branch March 2, 2026 14:51
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.49.0 release, scheduled for Tue, 17 Mar 2026.

@backstage-goalie backstage-goalie Bot added waiting-for:merge The PR has been approved and is awaiting merge. and removed waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:medium Medium-sized pull requests receive no change in priority for reviews. waiting-for:merge The PR has been approved and is awaiting merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants