Skip to content

Commit 60db90b

Browse files
natemoo-reandrewshie-sentry
authored andcommitted
fix(stories): flatten search tree (#95348)
Fixing a regression introduced in #95247, where the shared stories (hooks, views, product-specific components) were only surfacing the top-level tree nodes. To fix this, we need to flatten each category into an array of all leaf nodes before searching.
1 parent 1870366 commit 60db90b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

static/app/stories/view/storySearch.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ function isStorySection(item: StoryTreeNode | StorySection): item is StorySectio
3333

3434
export function StorySearch() {
3535
const inputRef = useRef<HTMLInputElement | null>(null);
36-
const {foundations, core, shared} = useStoryBookFilesByCategory();
36+
const {
37+
foundations: foundationsTree,
38+
core: coreTree,
39+
shared: sharedTree,
40+
} = useStoryBookFilesByCategory();
41+
const foundations = useMemo(
42+
() => foundationsTree.flatMap(tree => tree.flat()),
43+
[foundationsTree]
44+
);
45+
const core = useMemo(() => coreTree.flatMap(tree => tree.flat()), [coreTree]);
46+
const shared = useMemo(() => sharedTree.flatMap(tree => tree.flat()), [sharedTree]);
3747

3848
const storiesSearchHotkeys = useMemo(() => {
3949
return [{match: '/', callback: () => inputRef.current?.focus()}];
@@ -54,8 +64,8 @@ export function StorySearch() {
5464

5565
if (core.length > 0) {
5666
sections.push({
57-
key: 'core',
58-
label: 'Core',
67+
key: 'components',
68+
label: 'Components',
5969
options: core,
6070
});
6171
}

0 commit comments

Comments
 (0)