Skip to content

Commit

Permalink
fix: hide menu on click
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Sep 7, 2022
1 parent 8d07ea9 commit 74dc8c1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/website/src/components/SidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function SidebarLayout({
const toggleTheme = () => setTheme(resolvedTheme === 'light' ? 'dark' : 'light');
const matches = useMedia('(min-width: 992px)', false);
const [opened, setOpened] = useState(false);
const packageMenu = useMenuState({ gutter: 8, sameWidth: true });
const versionMenu = useMenuState({ gutter: 8, sameWidth: true });
const packageMenu = useMenuState({ gutter: 8, sameWidth: true, fitViewport: true });
const versionMenu = useMenuState({ gutter: 8, sameWidth: true, fitViewport: true });
// useLockBodyScroll(opened);

useEffect(() => {
Expand All @@ -78,6 +78,7 @@ export function SidebarLayout({
className="hover:bg-light-700 active:bg-light-800 dark:bg-dark-600 dark:hover:bg-dark-500 dark:active:bg-dark-400 rounded bg-white p-3 text-sm"
as="a"
state={packageMenu}
onClick={() => packageMenu.setOpen(false)}
>
{pkg}
</MenuItem>
Expand All @@ -93,6 +94,7 @@ export function SidebarLayout({
className="hover:bg-light-700 active:bg-light-800 dark:bg-dark-600 dark:hover:bg-dark-500 dark:active:bg-dark-400 rounded bg-white p-3 text-sm"
as="a"
state={versionMenu}
onClick={() => versionMenu.setOpen(false)}
>
{item}
</MenuItem>
Expand Down Expand Up @@ -198,7 +200,7 @@ export function SidebarLayout({
</div>
</MenuButton>
<Menu
className="dark:bg-dark-600 border-light-800 dark:border-dark-100 z-20 rounded border bg-white p-1"
className="dark:bg-dark-600 border-light-800 dark:border-dark-100 z-20 flex flex-col rounded border bg-white p-1"
state={packageMenu}
>
{packageMenuItems}
Expand All @@ -222,7 +224,7 @@ export function SidebarLayout({
</div>
</MenuButton>
<Menu
className="dark:bg-dark-600 border-light-800 dark:border-dark-100 z-20 rounded border bg-white p-1"
className="dark:bg-dark-600 border-light-800 dark:border-dark-100 z-20 flex flex-col rounded border bg-white p-1"
state={versionMenu}
>
{versionMenuItems}
Expand Down

1 comment on commit 74dc8c1

@vercel
Copy link

@vercel vercel bot commented on 74dc8c1 Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.