diff --git a/lib/ui/src/components/sidebar/Sidebar.tsx b/lib/ui/src/components/sidebar/Sidebar.tsx index 518eeb50c1fe..53f2b2adcdf4 100644 --- a/lib/ui/src/components/sidebar/Sidebar.tsx +++ b/lib/ui/src/components/sidebar/Sidebar.tsx @@ -105,7 +105,24 @@ export const Sidebar: FunctionComponent = React.memo( () => (DOCS_MODE ? collapseAllStories : collapseDocsOnlyStories)(storiesHash), [DOCS_MODE, storiesHash] ); - const dataset = useCombination(stories, storiesConfigured, storiesFailed, refs); + const adaptedRefs = useMemo(() => { + if (DOCS_MODE) { + return Object.keys(refs).reduce((acc: Refs, cur) => { + const ref = refs[cur]; + if (ref.stories) { + acc[cur] = { + ...ref, + stories: collapseDocsOnlyStories(ref.stories), + }; + } else { + acc[cur] = ref; + } + return acc; + }, {}); + } + return refs; + }, [DOCS_MODE, refs]); + const dataset = useCombination(stories, storiesConfigured, storiesFailed, adaptedRefs); const isLoading = !dataset.hash[DEFAULT_REF_ID].ready; const lastViewedProps = useLastViewed(selected);