facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.06k stars 8.41k forks source link

Persist sidebar state (categories expanded state, hidden sidebar) #6319

Open Josh-Cena opened 2 years ago

Josh-Cena commented 2 years ago

Have you read the Contributing Guidelines on issues?

Description

It would be useful to persist sidebar state like which categories are collapsed and if the sidebar is hidden or not in local storage (or session storage?), so that the user's navigation experience is not interrupted by, say, going to the blog briefly.

Has this been requested on Canny?

No

Motivation

Better UX

API design

Persist state in local storage / session storage and retrieve on sidebar first render. After #3811 we probably have a better way to control the collapsed state of individual categories.

Have you tried building it?

No

Self-service

erikvanoosten commented 1 year ago

On https://zio.dev/ecosystem/ the left-side navigation is pretty large. It would be nice if it automatically scrolls to the active page at load time. Is that part of this issue?

Josh-Cena commented 1 year ago

@erikvanoosten No, but unfortunately we had troubles with scroll-to-active features in the past: https://github.com/facebook/docusaurus/pull/6317, https://github.com/facebook/docusaurus/pull/6748, https://github.com/facebook/docusaurus/pull/6666 so it won't be soon that we introduce this feature to left sidebars.