diff --git a/.changeset/tasty-nails-cover.md b/.changeset/tasty-nails-cover.md new file mode 100644 index 0000000000..325b28746c --- /dev/null +++ b/.changeset/tasty-nails-cover.md @@ -0,0 +1,5 @@ +--- +"nextra-theme-docs": patch +--- + +fix unclickable `type: menu` on mobile nav diff --git a/packages/nextra-theme-docs/src/components/sidebar.tsx b/packages/nextra-theme-docs/src/components/sidebar.tsx index 80e799bd36..68393f4d01 100644 --- a/packages/nextra-theme-docs/src/components/sidebar.tsx +++ b/packages/nextra-theme-docs/src/components/sidebar.tsx @@ -59,9 +59,16 @@ type FolderProps = { level: number } -const Folder: FC = ({ item, anchors, onFocus, level }) => { +const Folder: FC = ({ item: _item, anchors, onFocus, level }) => { const routeOriginal = useFSRoute() const route = routeOriginal.split('#', 1)[0]! + + const item = { + ..._item, + children: + _item.type === 'menu' ? getMenuChildren(_item as any) : _item.children + } + const hasRoute = !!item.route // for item.type === 'menu' will be '' const active = hasRoute && [route, route + '/'].includes(item.route + '/') const activeRouteInside = @@ -96,8 +103,7 @@ const Folder: FC = ({ item, anchors, onFocus, level }) => { event.preventDefault() } const isOpen = el.parentElement!.classList.contains('open') - const route = el.getAttribute('href') || el.dataset.href || '' - TreeState[route] = !isOpen + TreeState[item.route] = !isOpen rerender({}) } @@ -157,10 +163,7 @@ const Folder: FC = ({ item, anchors, onFocus, level }) => { diff --git a/packages/nextra/src/client/components/banner/index.tsx b/packages/nextra/src/client/components/banner/index.tsx index d8803d7eae..57059027ab 100644 --- a/packages/nextra/src/client/components/banner/index.tsx +++ b/packages/nextra/src/client/components/banner/index.tsx @@ -24,7 +24,8 @@ export const Banner: FC<{ CLASS_NAME, 'x:max-md:sticky x:top-0 x:z-20 x:flex x:items-center', 'x:text-slate-50 x:dark:text-white x:bg-neutral-900 x:dark:bg-[linear-gradient(1deg,#383838,#212121)]', - 'x:px-2 x:print:hidden' + 'x:px-2', + 'x:print:[display:none]' // to not match `x:[.nextra-banner:not([class$=hidden])~&]` class )} >