Auto collapse navbar categories when menu item is selected
planned
Joshua Chen
planned
Krystian Babilinski
I'm going to push back on the "it feels like a bug"
Auto-collapse during route transition is what people are familiar with, it emphasizes where the page is located in the sidebar and shows how it relates to the parent categories. It also makes searching for a new item easier, since you can start with the outer categories first and then drill in.
Food ->Fruits -> Apples
Food -> Meats -> Birds -> Chicken
Without auto-collapsing the sidebar or providing a "clean up" button on the sidebar, users can find themselves navigating a fully expanded categories, which removes the purpose of the "collapsed" flag in the sidebar categories.
Joshua Chen
Krystian Babilinski: I see, maybe it's something we'd like to do, but the API is not easy to design because we don't want many different kinds of UXes and many people are happy with persisted category states... Have you tried the deploy preview in #3811 and decided if that's a sensible UX as well? Also, would https://docusaurus.io/feature-requests/p/collapse-expand-all-sections-button-in-sidebar, which is in our backlog, provide an alternative to your desired effect?
Krystian Babilinski
Joshua Chen: I think that's a valid solution, especially if it leaves the active page expanded.
Joshua Chen
We'll implement something similar in https://github.com/facebook/docusaurus/pull/3811, but probably different from what you have in mind. That "auto-collapse" looks more like a bug to me, because many websites can't properly preserve client state during route transitions. For us, we will allow sites to only keep one open category, but we probably won't auto-collapse during route transition because that sounds more annoying than useful, at least for me.
Joshua Chen
in progress
Sébastien Lorber
planned
Joshua Chen
In progress: https://github.com/facebook/docusaurus/pull/3811
I will work on this after the "category index pages"