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

Sonner loses state after portaling to a top layer <dialog> #534

Open
mkrause opened this issue Jan 9, 2025 · 0 comments
Open

Sonner loses state after portaling to a top layer <dialog> #534

mkrause opened this issue Jan 9, 2025 · 0 comments

Comments

@mkrause
Copy link

mkrause commented Jan 9, 2025

I'm trying to use sonner in an app that uses HTML <dialog> elements for modals. Due to the issues described here, in order to make this work with toast notifications, I need to use createPortal() to render the <Toaster/> inside the <dialog>. However, if I do this, any toasts that are already open get reset. The "re-portaling" from one location in the DOM to another makes it lose its component state.

Would it be possible to allow Toaster to be a controlled component? That is, allow toasts and setToasts to be passed in as props. That way, I can maintain this state in the parent component which does not get remounted and therefore the <Toaster/> element can be freely moved around.

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