From 74e93b3079c4d4926b52c9ac8469cea25dc3a8cf Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 6 May 2025 19:11:15 +0300 Subject: [PATCH] docs: fixes to navbar and sidebar in mobile (#12379) * docs: fixes to navbar and sidebar in mobile * fix height issues --- .../MainNav/MobileMenu/SubMenu/index.tsx | 4 ++-- .../components/MainNav/MobileMenu/index.tsx | 5 ++++- .../components/Sidebar/Item/Category/index.tsx | 18 ++++++++---------- .../src/hooks/use-click-outside/index.tsx | 3 ++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/www/packages/docs-ui/src/components/MainNav/MobileMenu/SubMenu/index.tsx b/www/packages/docs-ui/src/components/MainNav/MobileMenu/SubMenu/index.tsx index 150e19b399..74db4354d8 100644 --- a/www/packages/docs-ui/src/components/MainNav/MobileMenu/SubMenu/index.tsx +++ b/www/packages/docs-ui/src/components/MainNav/MobileMenu/SubMenu/index.tsx @@ -24,11 +24,11 @@ export const MainNavMobileSubMenu = ({ ) as (MenuItemLink | MenuItemSubMenu)[] }, [menu]) return ( -
+
{title} -
    +
      {filteredItems.map((item, index) => (
    • { nodeRef={ref} timeout={250} > -
      +
      {selectedMenus.length === 0 && ( )} diff --git a/www/packages/docs-ui/src/components/Sidebar/Item/Category/index.tsx b/www/packages/docs-ui/src/components/Sidebar/Item/Category/index.tsx index d4192796a1..bd3f990464 100644 --- a/www/packages/docs-ui/src/components/Sidebar/Item/Category/index.tsx +++ b/www/packages/docs-ui/src/components/Sidebar/Item/Category/index.tsx @@ -64,7 +64,13 @@ export const SidebarItemCategory = ({ }, [persistCategoryState]) const handleOpen = () => { - item.onOpen?.() + if (!open) { + item.onOpen?.() + } + if (persistCategoryState) { + updatePersistedCategoryState(item.title, !open) + } + setOpen((prev) => !prev) } const isTitleOneWord = useMemo( @@ -87,15 +93,7 @@ export const SidebarItemCategory = ({ !isTitleOneWord && "break-words" )} tabIndex={-1} - onClick={() => { - if (!open) { - handleOpen() - } - if (persistCategoryState) { - updatePersistedCategoryState(item.title, !open) - } - setOpen((prev) => !prev) - }} + onClick={handleOpen} > { - if (!elmRef.current?.contains(e.target as Node)) { + const node = e.target as Node + if (!elmRef.current?.contains(node) && node.isConnected) { onClickOutside(e) } },