Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sidebar sections always visible #4103

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/shared/src/components/sidebar/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ArrowIcon } from '../icons';
import type { SettingsFlags } from '../../graphql/settings';
import { useSettingsContext } from '../../contexts/SettingsContext';
import { isNullOrUndefined } from '../../lib/func';
import useSidebarRendered from '../../hooks/useSidebarRendered';

export interface SectionCommonProps
extends Pick<ItemInnerProps, 'shouldShowLabel'> {
Expand All @@ -22,6 +23,7 @@ interface SectionProps extends SectionCommonProps {
title?: string;
items: SidebarMenuItem[];
isItemsButton: boolean;
isAlwaysOpenOnMobile?: boolean;
}

export function Section({
Expand All @@ -33,9 +35,11 @@ export function Section({
isItemsButton,
className,
flag,
isAlwaysOpenOnMobile,
}: SectionProps): ReactElement {
const { flags, updateFlag } = useSettingsContext();

const { sidebarRendered } = useSidebarRendered();
const shouldAlwaysBeVisible = isAlwaysOpenOnMobile && !sidebarRendered;
const isVisible = useRef(
isNullOrUndefined(flags?.[flag]) ? true : flags[flag],
);
Expand Down Expand Up @@ -66,7 +70,7 @@ export function Section({
/>
</NavHeader>
)}
{isVisible.current &&
{(isVisible.current || shouldAlwaysBeVisible) &&
items.map((item) => (
<SidebarItem
key={`${item.title}-${item.path}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const BookmarkSection = ({
items={menuItems}
isItemsButton={isItemsButton}
flag={SidebarSettingsFlags.BookmarksExpanded}
isAlwaysOpenOnMobile
/>
);
};
Loading