Sidebar categories don't autocollapse correctly
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clearoryarn clearcommand. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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.
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.
autoCollapseCategories is actually not working at all, throwing a validation error: [ERROR] ValidationError: "docs.sidebar" is not allowed
Here's the fragment of themeConfig from my docusaurus.config.js:
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: {
sidebar: {
autoCollapseCategories: true,
},
},
autoCollapseCategoriesis 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
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.