-
-
Notifications
You must be signed in to change notification settings - Fork 10k
[Review Changes]: T2 - URL-based tag filter encoding + filter-aware initial story selection #34252
Copy link
Copy link
Closed
Labels
Description
Overview
Replace localStorage persistence for tag filters with URL-based state. Tag filter state is encoded in a tags URL parameter; status filter state is encoded in a separate statuses URL parameter (implemented in T7). Fix the existing bug where initial story selection ignores active tag filters when navigating to Storybook without a story path.
Scope
URL encoding (bidirectional sync):
- On startup, read the
tagsURL parameter from the current URL. Split on semicolons; entries prefixed with!go toexcludedTagFilters, all others toincludedTagFilters. Map only known built-in URL tags ($docs,$play,$test) to internal_-prefixed equivalents (e.g.,$docs→_docs); leave all other$...tags untouched - When any tag filter is toggled (via
addTagFilters,removeTagFilters,resetTagFilters,setAllTagFilters), serialize the current filter state into a singletagsURL parameter and update the URL. Tags are separated by semicolons. Built-in tags (internal_prefix) are serialized with$prefix (e.g.,_docs→$docs). Excluded tags are prefixed with!(e.g.,?tags=$docs;a11y;!experimental) - Remove
{ persistence: 'permanent' }from all tag filter mutations in file:code/core/src/manager-api/modules/stories.ts — filter state is URL-only, no localStorage - Remove the startup code that reads
includedTagFilters/excludedTagFiltersfrompersistedState(localStorage); replace with URL-based initialization
Filter-aware initial story selection (bug fix):
- Fix
selectFirstStory()in file:code/core/src/manager-api/modules/stories.ts to usefilteredIndexwhen filters are active, falling back toindexwhen no filters are active. IffilteredIndexis empty, suppress navigation - Fix the
STORY_SPECIFIEDhandler: whenisCanvasRouteis true and active filters exist, check whether the emittedstoryIdis present infilteredIndex. If not, navigate to the first story infilteredIndexinstead. IffilteredIndexis empty, suppress navigation entirely
Out of scope
- The
statusesURL parameter (T7) - Status-based filtering in the TagsFilterPanel (T7)
- Any server-side changes (T1, T3)
Acceptance Criteria
- Navigating to
?tags=playshows only stories taggedplayin the sidebar - Navigating to
?tags=a11y;!experimentalshows stories taggeda11ybut notexperimental - Unknown custom tags that start with
$are preserved as-is (not rewritten to_...) - Toggling a filter in the UI updates the URL immediately with semicolon-separated tags and
$prefix for built-in tags - Refreshing the page restores the same filter state from the URL
- No tag filter state is written to or read from localStorage
- Navigating to
http://localhost:6006/?tags=play(no story path) selects the first story that passes theplayfilter, not the first story in the full index - If
filteredIndexis empty on load, no story is selected and no navigation occurs
Reactions are currently unavailable