[Bug]: Storybook v7-rc.5 - switching between Docs and Story causes error when components depend on DOM element ids
#21,736 创建于 2023年3月22日
描述
Describe the bug
We have noticed that when using Docs in stories for components that depend on javascript that references the component's DOM elements IDs, those components present issues with their functionality when switching between Docs and the component Story. Seems it has to do with how the DOM is updated during the switch.
When storybook-root is active, all inner HTML is removed from storybook-docs. This doesn't happen when storybook-docs is active, influencing the ids referred by the code and breaking the module functionality inside the Docs.


To Reproduce
Open link in Chrome, go to the Accordion Story and try switching between the Docs and the Default story. You'll notice that at first the Accordion works fine in the Docs section, but once you have switched to the Default story and back to Docs it stops working, this has to do with the issue menitoned above.
System
Environment Info:
System:
OS: macOS 13.2.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 16.17.0 - ~/.local/share/nvm/v16.17.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.15.0 - ~/.local/share/nvm/v16.17.0/bin/npm
Browsers:
Chrome: 111.0.5563.64
Firefox: 107.0.1
Safari: 16.3
Additional context
No response