Skip to content

Commit

Permalink
Merge pull request #23781 from joaonunomota/expand-refs
Browse files Browse the repository at this point in the history
UI: Expand sidebar for selected story when using composition
  • Loading branch information
ndelangen authored Sep 19, 2023
2 parents cf5519b + 5c9099c commit 85ce31e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion code/ui/manager/src/components/sidebar/Refs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC, MutableRefObject } from 'react';
import React, { useMemo, useState, useRef, useCallback } from 'react';
import React, { useEffect, useMemo, useState, useRef, useCallback } from 'react';
import type { State } from '@storybook/manager-api';
import { useStorybookApi, useStorybookState } from '@storybook/manager-api';
import { styled } from '@storybook/theming';
Expand Down Expand Up @@ -131,6 +131,12 @@ export const Ref: FC<RefType & RefProps & { status?: State['status'] }> = React.
const state = getStateType(isLoading, isAuthRequired, isError, isEmpty);
const [isExpanded, setExpanded] = useState<boolean>(expanded);

useEffect(() => {
if (index && selectedStoryId && index[selectedStoryId]) {
setExpanded(true);
}
}, [setExpanded, index, selectedStoryId]);

const handleClick = useCallback(() => setExpanded((value) => !value), [setExpanded]);

const setHighlightedItemId = useCallback(
Expand Down

0 comments on commit 85ce31e

Please sign in to comment.