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

[Feat:Portal] Override default portal'd location #2845

Open
jd-carroll opened this issue Apr 17, 2024 · 0 comments
Open

[Feat:Portal] Override default portal'd location #2845

jd-carroll opened this issue Apr 17, 2024 · 0 comments

Comments

@jd-carroll
Copy link

When no container is provided to a Portal'd element (eg. Dialog), it is portal'd to the body through the use of a hard coded default location globalThis?.document?.body.

It would be nice if there was a way to override this default location, even if only in non-prod environments.

Use Case:
Testing dialogs (or any portal'd content) in Storybook leads to a lot of frustrations if you have applied any custom styles. Storybook will load your stories under "storybook-root", but the portal'd content (obviously) loads under body and not the "storybook-root".

Not really sure what this would look like, but it would be great if you could set some kind of global (eg. globalThis.RADIX_PORTAL_ROOT = '#storybook-root') with a selector. Then before falling back to the body, the portal could attempt to find the selector if any was provided.

For now I've gotten around this issue using a preview-body.html, but having this feature would be a lot easier.

🙏🏻

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

No branches or pull requests

1 participant