Repository navigation
fix: close a notification on detach - #3154
Conversation
| getElement().appendVirtualChild(container); | ||
|
|
||
| getElement().addEventListener("opened-changed", event -> { | ||
| addOpenedChangeListener(event -> { |
There was a problem hiding this comment.
An "opened-changed" event only works if the Flow component doesn't get detached from its parent while the <vaadin-notification> Web Component is showing. Then we could rely on the DOM event to take care of getting this callback invoked.
But if the Flow component gets detached before the notification actually closes, the Web Component becomes an "orphan" without an active Flow counterpart and the following "opened-changed" event never reaches the callback.
|
|
||
| // If the notificaiton gets detached, it needs to be marked as closed so | ||
| // it won't auto-open when reattached. | ||
| setOpened(false); |
There was a problem hiding this comment.
Just to make sure, this will trigger the openedChanged listener above bypassing the client-side, right?
There was a problem hiding this comment.
That was the intention but it seems there was some timing issue, so I needed to change the logic. Let's see if the newest revision passes.
| Notification notification = Notification.show( | ||
| "This is a notification created with static convenience method"); | ||
| notification.setId("static-notification"); | ||
| addCard("Notification using static convenience method", notification); |
There was a problem hiding this comment.
The test setup here was strange (yet supported): the notification was first auto-added to UI using Notification.show() but then the same instance got manually added to the card.
The assertion in the related test however was wrong. It assumed that the instance would automatically get removed from its parent on close even though it's manually re-added in the setup. This used to work because the order of checking the condition and beforeClientResponse was kind of backwards (this PR fixes the order & adds a related test).
|
Kudos, SonarCloud Quality Gate passed!
|
|
Hi @tomivirkki and @tomivirkki, when i performed cherry-pick to this commit to 23.0, i have encountered the following issue. Can you take a look and pick it manually? |
|
Hi @tomivirkki and @tomivirkki, when i performed cherry-pick to this commit to 14.8, i have encountered the following issue. Can you take a look and pick it manually? |








Fixes #3085