Core: Fix removeScrollOn on sidebar primitive

This commit is contained in:
Fuma Nama
2025-04-04 21:44:34 +08:00
parent cabc526879
commit c66ed79897
5 changed files with 10 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-core': patch
---
Fix `removeScrollOn` on sidebar primitive
-4
View File
@@ -3,10 +3,6 @@ title: Async Mode
description: Runtime compilation of content files.
---
<Callout type="warn" title="Experimental">
This feature is still experimental, use it under your own risk.
</Callout>
## Introduction
By default, all Markdown and MDX files need to be pre-compiled first, the same constraint also applies on development server.
+3 -3
View File
@@ -91,7 +91,7 @@ export type SidebarContentProps<T extends ElementType> = AsProps<T> & {
*
* When the sidebar is opening and media query is matched, scrolling outside the sidebar will be blocked.
*
* @example (min-width: 1000px)
* @example (max-width: 1000px)
*/
removeScrollOn?: string;
};
@@ -100,7 +100,7 @@ export function SidebarList<T extends ElementType = 'aside'>({
as,
blockScrollingWidth,
removeScrollOn = blockScrollingWidth
? `(min-width: ${blockScrollingWidth}px)`
? `(width < ${blockScrollingWidth}px)`
: undefined,
...props
}: SidebarContentProps<T>): ReactElement {
@@ -112,7 +112,7 @@ export function SidebarList<T extends ElementType = 'aside'>({
const mediaQueryList = window.matchMedia(removeScrollOn);
const handleChange = (): void => {
setIsBlocking(!mediaQueryList.matches);
setIsBlocking(mediaQueryList.matches);
};
handleChange();
mediaQueryList.addEventListener('change', handleChange);
@@ -86,7 +86,7 @@ function Sidebar() {
return (
<SidebarPrimitive.SidebarList
removeScrollOn="(min-width: 768px)" // md
removeScrollOn="(width < 768px)" // md
className={cn(
'fixed flex flex-col shrink-0 p-4 top-14 z-20 text-sm overflow-auto md:sticky md:h-[calc(100dvh-56px)] md:w-[300px]',
'max-md:inset-x-0 max-md:bottom-0 max-md:bg-fd-background',
@@ -151,7 +151,7 @@ export function Sidebar({
<Context.Provider value={context}>
<Base.SidebarList
id="nd-sidebar"
removeScrollOn="(min-width: 768px)" // md
removeScrollOn="(width < 768px)" // md
{...props}
className={cn(
'fixed top-[calc(var(--fd-banner-height)+var(--fd-nav-height))] z-20 bg-fd-card text-sm md:sticky md:h-(--fd-sidebar-height)',