docs: fixes to navbar and sidebar in mobile (#12379)

* docs: fixes to navbar and sidebar in mobile

* fix height issues
This commit is contained in:
Shahed Nasser
2025-05-06 19:11:15 +03:00
committed by GitHub
parent 91173f3052
commit 74e93b3079
4 changed files with 16 additions and 14 deletions

View File

@@ -24,11 +24,11 @@ export const MainNavMobileSubMenu = ({
) as (MenuItemLink | MenuItemSubMenu)[]
}, [menu])
return (
<div className="flex flex-col gap-[23px]">
<div className="flex flex-col gap-[23px] max-h-[90%]">
<span className="text-compact-small-plus text-medusa-fg-muted uppercase">
{title}
</span>
<ul className="flex flex-col gap-[18px]">
<ul className="flex flex-col gap-[18px] max-h-full overflow-auto">
{filteredItems.map((item, index) => (
<li
key={index}

View File

@@ -52,7 +52,10 @@ export const MainNavMobileMenu = () => {
nodeRef={ref}
timeout={250}
>
<div ref={ref} className="w-full px-docs_1.5">
<div
ref={ref}
className="w-full px-docs_1.5 h-3/4 flex flex-col justify-center"
>
{selectedMenus.length === 0 && (
<MainNavMobileMainMenu setSelectedMenus={setSelectedMenus} />
)}

View File

@@ -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}
>
<span
className={clsx(

View File

@@ -16,7 +16,8 @@ export const useClickOutside = ({
const checkClickOutside = useCallback(
(e: MouseEvent) => {
if (!elmRef.current?.contains(e.target as Node)) {
const node = e.target as Node
if (!elmRef.current?.contains(node) && node.isConnected) {
onClickOutside(e)
}
},