-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Bug]: Unable to paste from clipboard in v9 #31626
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
Comments
This seems to be caused by The real problem here is that the "Copy" functionality from Docs lives in the preview rather than in the manager, and therefore it is affected by any kind of mocking that happens for the story. Your own Button component story is supposed to have this mocking applied, so that it can be tested. We could consider passing |
I've tried to resolve this by adding |
I found a much simpler solution. By using the clipboard from the top frame ( |
Thank you for the quick fix!! |
Local copyToClipboard calls inside Storybook still use the preview iframe, which remains sandboxed even after this PR so clipboard writes resolve but the system clipboard isn’t updated. The actual fix would require adding allow="clipboard-write" (or delegating to window.top.clipboard) on the iframe itself to fully restore copy functionality. |
Reopening this because we should find a general solution for clipboard behavior in user components as well. |
Hi! |
Yes, I've opened an issue with user-event and also created a workaround to undo the clipboard stub. |
Describe the bug
Using the
navigator.clipboard
API doesn't work like it used to. I can confirm that I am able towriteText
andreadText
fine, but when I go to paste it doesn't work. I see there isallow="clipboard-write"
in both versions so I'm not sure what changed.Reproduction link
https://stackblitz.com/edit/github-slbxsupt?file=src%2Fstories%2FButton.tsx&preset=node
Reproduction steps
"this can't be pasted anywhere"
System
Additional context
I verified it was working in
v8.6.14
. Here is the info from my PR prior to upgrading to v9.Storybook Environment Info:
System:
OS: macOS 15.5
CPU: (16) arm64 Apple M3 Max
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.volta/tools/image/node/22.14.0/bin/node
Yarn: 1.22.22 - ~/.volta/tools/image/yarn/1.22.22/bin/yarn
npm: 10.2.5 - ~/.volta/tools/image/npm/10.2.5/bin/npm
Browsers:
Chrome: 137.0.7151.56
Safari: 18.5
npmPackages:
@storybook/addon-a11y: 8.6.14 => 8.6.14
@storybook/addon-essentials: 8.6.14 => 8.6.14
@storybook/addon-interactions: 8.6.14 => 8.6.14
@storybook/blocks: 8.6.14 => 8.6.14
@storybook/react-vite: 8.6.14 => 8.6.14
@storybook/test: 8.6.14 => 8.6.14
eslint-plugin-storybook: 0.12.0 => 0.12.0
storybook: 8.6.14 => 8.6.14
storybook-addon-rtl: 1.1.0 => 1.1.0
storybook-dark-mode: 4.0.2 => 4.0.2
The text was updated successfully, but these errors were encountered: