Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: docs-page table-of-contents does not scroll and highlight current paragraph, if not enough height available #26347

Open
kroeder opened this issue Mar 6, 2024 · 3 comments · May be fixed by #26470

Comments

@kroeder
Copy link
Member

kroeder commented Mar 6, 2024

Describe the bug

In docs page, if you click on a table-of-contents item, and there is not enough height available in the docs page, it actually does not change the current state of the table-of-contents.

table-of-contents

At work, I dealt with a similar issue (horizontal tabs with scrollable content section). What we did was to use a hidden element that adds as many height as needed to be able to scroll to even the last element in all cases. It produces lots of unused space at the bottom but from a UX perspective, you can now use the toc and scroll + show the current active toc item in all cases.

Specifically, we use a resizeObserver to check if the user browser height changes. If it does, we calculate and apply the needed additional height.

To Reproduce

ttps://stackblitz.com/edit/github-w91kck?file=.storybook%2Fpreview.ts

  • Open docs page
  • Click on an item and see the same result as in the video capture above

System

No response

Additional context

Alternative solution; Do not add a hidden container at the bottom, leave everything at is but at least underline the last clicked "toc" element. After user-scroll, this obviously would change again but is still less confusing IMO

@vanessayuenn
Copy link
Contributor

At work, I dealt with a similar issue (horizontal tabs with scrollable content section). What we did was to use a hidden element that adds as many height as needed to be able to scroll to even the last element in all cases. It produces lots of unused space at the bottom but from a UX perspective, you can now use the toc and scroll + show the current active toc item in all cases.

Specifically, we use a resizeObserver to check if the user browser height changes. If it does, we calculate and apply the needed additional height.

This seems like a good approach! However, I don't think the team will have capacity to implement this in near future. But PRs are most certainly welcome! ✨

For anyone interested in taking this on: be sure to check the contribution guide and hop onto the Storybook Discord if you need any help getting started.

@maudem
Copy link

maudem commented Mar 6, 2024

@vanessayuenn Do you mind if I take this?

@vanessayuenn
Copy link
Contributor

Please do @maudem! Be sure to check the contribution guide and hop onto the Storybook Discord if you need any help getting started. Looking forward to your contribution! ✨

GustavoCostaHenriques added a commit to GustavoCostaHenriques/storybook that referenced this issue Mar 12, 2024
In docs page, if you click on a table-of-contents item, and there is not enough height available in the docs page, it does not change the current state of the table-of-contents.
To fix this bug a blank space is added at the end of the page to give it enough height.
@GustavoCostaHenriques GustavoCostaHenriques linked a pull request Mar 13, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants