-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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]: [tests] within(canvasElement)
cannot find elements rendered via portal to the document.body
#26963
Comments
Instead of |
I actually seems my types issue are not related to Storybook version. when I use I'm using:
|
UPDATE: @valentinpalkovic - Okay, I'm not sure where did I get that other stackblitz example from; but here is an up-to-date as of today: https://stackblitz.com/edit/github-yrt7dh?file=src%2Fstories%2FPage.stories.ts&preset=node Which is failing the same TypeScript error I'm experiencing locally |
@csantos1113 the error isn't coming from any of the libraries you mentioned but from the nature of DOM being untyped. TypeScript can't guarantee that your I see 2 possible options here:
I had a very similar problem when testing Radix components that use portals. You may find some inspiration in this PR. |
I will close this issue since a solution was provided and the Typescript issue was elaborated above |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
https://github.com/storybookjs/storybook/tree/next/code/lib/test says I should be using
within(canvasElement)
in my play functions, instead ofscreen
. but it doesn't work for portal elements rendered to the document.bodyTo Reproduce
screen.getByText
works, but shows a warning in the console saying that I should usewithin(canvasElement)
insteadcanvas.getByText
fails because the element is rendered via portal to the document.bodySystem
Additional context
Real live case: I'm opening a Dialog/Drawer which is rendered via portals.
Any recommendation on how to reach elements rendered via portals to the document.body that adheres to the expected behavior defined by Storybook?
The text was updated successfully, but these errors were encountered: