Skip to content

feat: persist active tab in TabList via URL search param#72

Merged
fedepini merged 3 commits into
mainfrom
feat/tablist-persistence
Jul 9, 2026
Merged

feat: persist active tab in TabList via URL search param#72
fedepini merged 3 commits into
mainfrom
feat/tablist-persistence

Conversation

@fedepini

@fedepini fedepini commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • TabList now persists the active tab in the URL as a search parameter (tab-<uid>)
  • The active tab survives page refresh and is shareable via URL
  • Tab switches use replace (not push) to avoid polluting browser history
  • Existing search params (including widgetEndpoint) are preserved when a tab changes

Implementation

The change is contained entirely in src/widgets/TabList/TabList.tsx:

  • useSearchParams reads and writes the active tab key
  • The param is namespaced per widget instance (tab-<uid>) so multiple TabLists on the same page don't collide
  • Before applying the stored key, it is validated against the current tab items — if the tab no longer exists (e.g. YAML was updated), it silently falls back to tab 0

Behaviour across navigation scenarios

Scenario What happens
User selects tab 2, then refreshes the page URL is preserved → lands on tab 2 ✓
User selects tab 2, copies and shares the URL Recipient lands on tab 2 ✓
User clicks the browser back button after switching tabs Goes to the previous page, not the previous tab (because tab switches use replace) ✓
Panel click → path navigate to a page containing a TabList Clean URL, TabList starts at tab 0 (fresh navigation, no prior tab context) ✓
Panel click → resourceRefId navigate on the same page URL becomes ?widgetEndpoint=<encoded> — tab param stripped, but TabList is not rendered in this state ✓
User navigates away via a nav menu item and comes back via the same item Fresh URL, tab 0 (expected reset on intentional navigation) ✓
Multiple TabLists on the same page Each uses its own tab-<uid> param — no collisions ✓
YAML updated and the previously active tab no longer exists Falls back silently to tab 0 ✓

Test plan

  • Open a page with a TabList, switch to a non-default tab, refresh — confirm landing on the same tab
  • Open the URL in a second browser tab — confirm both show the same active tab
  • Switch tabs several times, press browser back — confirm going to the previous page, not cycling through tab history
  • Verify that pages with two or more TabLists persist each independently
  • Trigger a navigate action from a widget on the same page — confirm tab param does not interfere

🤖 Generated with Claude Code

@fedepini fedepini merged commit ce1b3b4 into main Jul 9, 2026
3 checks passed
@fedepini fedepini deleted the feat/tablist-persistence branch July 9, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant