Fix URL hash loss and spurious history entries in GlTabs query param sync
What does this MR do?
Fixes 3 small bugs in GlTabs when syncActiveTabWithQueryParams is enabled.
1. The URL hash is dropped. setQueryParamValueIfNecessary() built the pushed URL from pathname + search only, so any #anchor was lost whenever the tab param was written. The URL is now built from window.location.href and reassembled as pathname + search + hash.
2. A negative tab index writes ?tab=-1. b-tabs uses -1 as its v-model value for "no tab is active". Two cases reach a mounted page: every tab being disabled, and the last tab unmounting. getTabQueryParamValue(-1) falls back to the index, so the URL gained ?tab=-1 — twice in the all-disabled case, which emits -1 on each pass. setQueryParamValueIfNecessary() now returns early for a negative tabIndex.
3. The first tab pushes a duplicate history entry. The dedupe check was gated on tabIndex !== 0, so activating the first tab while the URL already held its query param value fell through and pushed the same URL again.
Spec changes are additive — three new cases, each of which fails without the fix: hash preservation, a negative index writing nothing, and no duplicate history entry when the first tab's value already matches the URL.
Screenshots or screen recordings
| Before | After |
|---|---|
Integrations
No component API change, so no integration MRs are needed.
Does this MR meet the acceptance criteria?
Conformity
- The “What does this MR do?” section in the MR description is filled out.
- Relevant label(s) are applied to the MR.
- The MR is added to a milestone.
- Added the
~"component:*"label(s) if applicable. - A changeset is added (
patch). Seedoc/changesets.md.
Components
- GitLab UI's contributing guidelines.
- No component API change.