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

[v4] fix unclickable type: menu on mobile nav #3847

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/tasty-nails-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextra-theme-docs": patch
---

dd
dimaMachina marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 11 additions & 8 deletions packages/nextra-theme-docs/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ type FolderProps = {
level: number
}

const Folder: FC<FolderProps> = ({ item, anchors, onFocus, level }) => {
const Folder: FC<FolderProps> = ({ 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 =
Expand Down Expand Up @@ -95,9 +102,8 @@ const Folder: FC<FolderProps> = ({ item, anchors, onFocus, level }) => {
if (isClickOnIcon) {
event.preventDefault()
}
const isOpen = el.parentElement!.classList.contains('open')
const route = el.getAttribute('href') || el.dataset.href || ''
TreeState[route] = !isOpen
const open = el.parentElement!.classList.contains('open')
TreeState[item.route] = !open
dimaMachina marked this conversation as resolved.
Show resolved Hide resolved
rerender({})
}

Expand Down Expand Up @@ -157,10 +163,7 @@ const Folder: FC<FolderProps> = ({ item, anchors, onFocus, level }) => {
<Menu
className={classes.border}
// @ts-expect-error -- fixme
directories={
// @ts-expect-error -- fixme
item.type === 'menu' ? getMenuChildren(item) : item.children
}
directories={item.children}
anchors={anchors}
level={level}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/nextra/src/client/components/banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
)}
>
<div className="x:w-full x:whitespace-nowrap x:overflow-x-auto x:text-center x:font-medium x:text-sm">
Expand Down
Loading