fuma-nama / fumadocs

The beautiful docs framework with Next.js. Alternative to Nextra
https://fumadocs.vercel.app
MIT License
1.92k stars 116 forks source link

defaultOpenLevel sidebar prop not working #1085

Closed ZYJLiu closed 1 week ago

ZYJLiu commented 1 week ago

To Reproduce

The sidebar tab remains closed by even though defaultOpenLevel: 1

  1. Create new fumadocs project using npm create fumadocs-app

  2. Create content/docs/test/test.mdx to display "test.mdx" under a "test" tab in sidebar

CleanShot 2024-11-20 at 14 49 30@2x
  1. Update app/docs/layout.tsx with sidebar={{ defaultOpenLevel: 1 }}
import { DocsLayout } from "fumadocs-ui/layouts/docs";
import type { ReactNode } from "react";
import { baseOptions } from "@/app/layout.config";
import { source } from "@/lib/source";

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <DocsLayout
      tree={source.pageTree}
      {...baseOptions}
      sidebar={{ defaultOpenLevel: 1 }}
    >
      {children}
    </DocsLayout>
  );
}

Current vs. Expected behavior

Currently, folders in sidebar remain closed when using defaultOpenLevel prop.

The expected behavior is that they open to the specified level.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: 1.22.1
  pnpm: 9.1.2
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: 15.0.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

UI

Additional context

No response

fuma-nama commented 1 week ago

Oh yes the initial sidebar level was mistakenly increased to 1, should be fixed now

ZYJLiu commented 5 days ago

defaultOpenLevel still doesn't seem to work, using 14.5.2

fuma-nama commented 5 days ago

The fix is on the latest version, have you updated?

ZYJLiu commented 2 days ago

working now with 14.5.4, ty!