summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-01-10 10:30:57 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-01-15 11:43:19 +0200
commit9e54760b68b7682566a41827b3e2ef235da895ab (patch)
treec8fc60189e8e0781587a67d7ccd77982b8f5e0fd /client
parent531320c5051b7f72c9d96c7826b5cd4f9dcaae67 (diff)
downloadvaadin-framework-9e54760b68b7682566a41827b3e2ef235da895ab.tar.gz
vaadin-framework-9e54760b68b7682566a41827b3e2ef235da895ab.zip
Backport fix for removing Notifications on close (#10504)
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/notification/NotificationConnector.java32
1 files changed, 23 insertions, 9 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/notification/NotificationConnector.java b/client/src/main/java/com/vaadin/client/ui/notification/NotificationConnector.java
index 038d70dbf3..a0c49af8a3 100644
--- a/client/src/main/java/com/vaadin/client/ui/notification/NotificationConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/notification/NotificationConnector.java
@@ -36,6 +36,8 @@ import com.vaadin.ui.Notification;
@Connect(value = Notification.class)
public class NotificationConnector extends AbstractExtensionConnector {
+ private VNotification notification;
+
@Override
public NotificationState getState() {
return (NotificationState) super.getState();
@@ -44,21 +46,33 @@ public class NotificationConnector extends AbstractExtensionConnector {
@Override
protected void extend(ServerConnector target) {
NotificationState state = getState();
- VNotification n = VNotification.showNotification(
- target.getConnection(),
- state.caption, state.description,
- state.htmlContentAllowed, getResourceUrl("icon"),
- state.styleName, state.position, state.delay);
+ notification = VNotification.showNotification(target.getConnection(),
+ state.caption, state.description, state.htmlContentAllowed,
+ getResourceUrl("icon"), state.styleName, state.position,
+ state.delay);
- n.addCloseHandler(new CloseHandler<PopupPanel>() {
+ notification.addCloseHandler(new CloseHandler<PopupPanel>() {
@Override
public void onClose(CloseEvent<PopupPanel> event) {
- NotificationServerRpc rpc =
- getRpcProxy(NotificationServerRpc.class);
- rpc.closed();
+ if (getParent() == null) {
+ // Unregistered already
+ return;
+ }
+ NotificationServerRpc rpc = getRpcProxy(
+ NotificationServerRpc.class);
+ rpc.closed();
+ notification = null;
}
});
}
+ @Override
+ public void onUnregister() {
+ super.onUnregister();
+ if (notification != null) {
+ notification.hide();
+ notification = null;
+ }
+ }
}