docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Sidebar categories don't autocollapse correctly

Open dustinlacewell opened this issue 3 years ago • 1 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] I'm using the latest version of Docusaurus.
  • [X] I have tried the npm run clear or yarn clear command.
  • [X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [X] I have tried creating a repro with https://new.docusaurus.io.
  • [X] I have read the console error message carefully (if applicable).

Description

I am able to get multiple categories to be open at once.

See here:

Reproducible demo

No response

Steps to reproduce

I am honestly not sure. I'm not doing anything strange and it doesn't happen on the playground...

Expected behavior

Only one category should be expanded with autoCollapseCategories being true.

Actual behavior

Sometimes it is possible to get multiple categories to be expanded as once.

Your environment

  • Docusaurus version used: 2.0.1

Self-service

  • [ ] I'd be willing to fix this bug myself.

dustinlacewell avatar Aug 24 '22 05:08 dustinlacewell

Please create a simple repro and give us clear steps. If you can reproduce it on our own Docusaurus website, that's fine for me but give us the page link to start from and where to click exactly. I couldn't reproduce.

It's definitively possible that we have a bug. Afaik the implementation we did for that feature had some edge cases and doing something better would have required some more complex refactoring.

slorber avatar Aug 24 '22 09:08 slorber

autoCollapseCategories is actually not working at all, throwing a validation error: [ERROR] ValidationError: "docs.sidebar" is not allowed

caphesuagey avatar Mar 09 '23 09:03 caphesuagey

Here's the fragment of themeConfig from my docusaurus.config.js:

themeConfig:
    /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
    ({
      docs: {
        sidebar: {
          autoCollapseCategories: true,
        },
      },

caphesuagey avatar Mar 09 '23 09:03 caphesuagey

autoCollapseCategories is actually not working at all, throwing a validation error: [ERROR] ValidationError: "docs.sidebar" is not allowed

Most likely you try to add this to plugin options instead of themeConfig. We do use it on our own website as well as many other users so make sure you double-check where you add this attribute.

https://docusaurus.io/docs/sidebar#auto-collapse-sidebar-categories

Closing this issue because op didn't answer

slorber avatar Mar 09 '23 15:03 slorber

The only reason it didn't work is because I was on Docusaurus 2.0.0. Running yarn upgrade @docusaurus/core@latest @docusaurus/module-type-aliases@latest ││ @docusaurus/preset-classic@latest fixed the problem.

caphesuagey avatar Mar 10 '23 03:03 caphesuagey