Skip to content

[Bug]: tocbot is no longer exposed globally as of SB9 #31449

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

Open
JamesIves opened this issue May 11, 2025 · 1 comment
Open

[Bug]: tocbot is no longer exposed globally as of SB9 #31449

JamesIves opened this issue May 11, 2025 · 1 comment

Comments

@JamesIves
Copy link
Contributor

JamesIves commented May 11, 2025

Describe the bug

In the updated @storybook/addon-docs package, the tocbot global object is no longer exposed. This prevents documentation sites from running tocbot.refresh for content that is lazy loaded on the page.

Use case: We have some content that is fetched from a remote host on our documentation site that appends a new header to the page. We use this feature to re-init tocbot so the table fo contents update once it has loaded. This was previously exposed in SB8.

Reproduction link

N/A

Reproduction steps

  1. Attempt to call window.tocbot, you will get undefined. This is defined in SB8.
  2. As a result you can no longer call tocbot.refresh.

System

"@storybook/addon-docs": "9.0.0-beta.11"

Additional context

No response

@JamesIves JamesIves changed the title [Bug]: tocbot is no longer exposed globally [Bug]: tocbot is no longer exposed globally as of SB9 May 11, 2025
Copy link
Contributor

greptile-apps bot commented May 11, 2025

** Disclaimer** This information might be inaccurate, due to it being generated automatically
The tocbot functionality was previously exposed globally but is now encapsulated. To fix this: 1. In code/addons/docs/src/blocks/DocsContainer.tsx, locate where tocbot is initialized 2. Add this code after tocbot initialization: ts if (typeof window !== 'undefined') { window.tocbot = tocbot; } This will re-expose the tocbot instance globally while maintaining the existing functionality.

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Edit Issue Bot Settings · Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants