Skip to content

Commit

Permalink
Merge pull request #307 from chromaui/232-when-there-are-multiple-con…
Browse files Browse the repository at this point in the history
…nected-storybooks

Hide refs (composed Storybooks) while guided tour is active
  • Loading branch information
ghengeveld authored May 15, 2024
2 parents c4aa495 + 458e346 commit 926e6b1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/screens/GuidedTour/GuidedTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ export const GuidedTour = ({
const [stepIndex, setStepIndex] = useSessionState("stepIndex", 0);
const nextStep = () => setStepIndex((prev = 0) => prev + 1);

useEffect(() => {
// Hide composed Storybooks (refs) in the sidebar while the guided tour is active.
const explorer = document.getElementById("storybook-explorer-tree");
const refElements = Array.from(explorer instanceof HTMLElement ? explorer.children : [])
.filter((el): el is HTMLElement => el instanceof HTMLElement)
.slice(1);

// eslint-disable-next-line no-param-reassign, no-return-assign
refElements.forEach((el) => (el.style.display = "none"));

// eslint-disable-next-line no-param-reassign, no-return-assign
return () => refElements.forEach((el) => (el.style.display = ""));
}, []);

useEffect(() => {
// Listen for internal event to indicate a filter was set before moving to next step.
managerApi.once(ENABLE_FILTER, () => {
Expand Down

0 comments on commit 926e6b1

Please sign in to comment.