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-mode table-of-contents does not change URL when clicking on an anchor #26345

Open
kroeder opened this issue Mar 6, 2024 · 4 comments · May be fixed by #26459 or #26482
Open

[Bug]: docs-mode table-of-contents does not change URL when clicking on an anchor #26345

kroeder opened this issue Mar 6, 2024 · 4 comments · May be fixed by #26459 or #26482

Comments

@kroeder
Copy link
Member

kroeder commented Mar 6, 2024

Describe the bug

If you enable toc: true, docs-mode renders a table-of-contents inside the docs page.
When clicking on one of the toc list-items, the expected behavior would be to add the # anchor to the browser URL.

It should behave the same as clicking the # icon on a docs-page headline.

To Reproduce

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

  • Open "Button / Docs"
  • Click on table of contents anchor -> nothing is added to the URL

System

No response

Additional context

No response

@vanessayuenn
Copy link
Contributor

@kroeder in the repro you provided, the TOC does link to the # anchor. Can you clarify how do you expect it to work differently?

@ftr93
Copy link

ftr93 commented Mar 6, 2024

@vanessayuenn yes, it links to the anchor correctly, but clicking it doesn't change the browser URL

@sooster910
Copy link

sooster910 commented Mar 7, 2024

I have confirmed the behavior @kroeder described: When hovering over the anchor tag, as shown in the image below, it behaves as expected. However, upon clicking, the browser URL does not update to reflect the clicked anchor tag.
It is supposed to scroll down to where the anchor tag is located.

image

@vanessayuenn Can I give it a try? Thanks.

@vanessayuenn
Copy link
Contributor

@sooster910 of course! We'd be thrilled to have your contribution. If this is your first contribution, be sure to check the contribution guide and hop onto the Storybook Discord if you need any help getting started. Looking forward to your PR! ✨

Diogorrib added a commit to Diogorrib/storybook that referenced this issue Mar 12, 2024
Bug - When toc:true is enabled, docs-mode renders a table-of-contents inside the docs page. Clicking a toc list-item does not change the URL.
Solution - Add a function so that the URL changes when clicking on a toc list-item.
@Diogorrib Diogorrib linked a pull request Mar 12, 2024 that will close this issue
8 tasks
@sooster910 sooster910 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
4 participants