Skip to content

Commit 91391e4

Browse files
authored
fix: let sidebar squad lists expand without clipping (#5905)
1 parent 9782953 commit 91391e4

1 file changed

Lines changed: 27 additions & 17 deletions

File tree

packages/shared/src/components/sidebar/Section.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,20 @@ export function Section({
4444
const { flags, updateFlag } = useSettingsContext();
4545
const { sidebarRendered } = useSidebarRendered();
4646
const shouldAlwaysBeVisible = isAlwaysOpenOnMobile && !sidebarRendered;
47-
const isVisible = useRef(
48-
isNullOrUndefined(flags?.[flag]) ? true : flags[flag],
49-
);
47+
const currentFlagValue = flag ? flags?.[flag] : undefined;
48+
const initialIsVisible = isNullOrUndefined(currentFlagValue)
49+
? true
50+
: currentFlagValue;
51+
const isVisible = useRef(initialIsVisible);
52+
5053
const toggleFlag = () => {
51-
updateFlag(flag, !isVisible.current);
52-
isVisible.current = !isVisible.current;
54+
const nextIsVisible = !isVisible.current;
55+
56+
if (flag) {
57+
updateFlag(flag, nextIsVisible);
58+
}
59+
60+
isVisible.current = nextIsVisible;
5361
};
5462

5563
return (
@@ -121,21 +129,23 @@ export function Section({
121129
<div
122130
id={flag ? `section-${flag}` : undefined}
123131
className={classNames(
124-
'flex flex-col overflow-hidden transition-all duration-300',
132+
'grid transition-[grid-template-rows,opacity] duration-300',
125133
isVisible.current || shouldAlwaysBeVisible
126-
? 'max-h-[2000px] opacity-100'
127-
: 'max-h-0 opacity-0',
134+
? 'grid-rows-[1fr] opacity-100'
135+
: 'grid-rows-[0fr] opacity-0',
128136
)}
129137
>
130-
{items.map((item) => (
131-
<SidebarItem
132-
key={`${item.title}-${item.path}`}
133-
item={item}
134-
activePage={activePage}
135-
isItemsButton={isItemsButton}
136-
shouldShowLabel={shouldShowLabel}
137-
/>
138-
))}
138+
<div className="flex min-h-0 flex-col overflow-hidden">
139+
{items.map((item) => (
140+
<SidebarItem
141+
key={`${item.title}-${item.path}`}
142+
item={item}
143+
activePage={activePage}
144+
isItemsButton={isItemsButton}
145+
shouldShowLabel={shouldShowLabel}
146+
/>
147+
))}
148+
</div>
139149
</div>
140150
</NavSection>
141151
);

0 commit comments

Comments
 (0)