Prevent notification from closing, when a modal dialog is closed

If you open a notification while a modal dialog is open, and then close the dialog - it will dismiss the notification as well.
This is a known issue [Notification] Closing a dialog also removes the notification · Issue #3588 · vaadin/flow-components · GitHub
The suggested workaround is to switch off the dialog “modality”, but this is not a preferred solution. Is there another workaround that would preserve the dialog modality?
We don’t need this to be the case for all notifications, just some specific ones.

I assume you are using Notification.show. When you use that the notification automatically gets added as a child to the current modal dialog. To work around this you can:

1 Like

Thanks Sascha!
We were create a Notification, but not attaching to anything, just calling .open() on it.
Adding it to the UI does produce the desired result, thanks!

Right, makes sense. Note that you’ll also have to remove the notification manually after it is closed, unless you intend to reuse it.

1 Like