diff options
author | Tatu Lund <tatu@vaadin.com> | 2019-06-07 13:14:38 +0300 |
---|---|---|
committer | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-07 13:14:38 +0300 |
commit | 7a453dce177d849305c549296986eb21e171bae0 (patch) | |
tree | fdff2d68f8bbbf9f34b1cbf9d6184de133154d82 /server | |
parent | a6a21157c426aed6a0211bc0a3f6a5056f1e455e (diff) | |
download | vaadin-framework-7a453dce177d849305c549296986eb21e171bae0.tar.gz vaadin-framework-7a453dce177d849305c549296986eb21e171bae0.zip |
Fix regression that broke PreserveOnRefresh functionality with Navigator (#11615)
* Fix regression that broke PreserveOnRefresh functionality with Navigator
Fixes https://github.com/vaadin/framework/issues/11614
Old patch https://github.com/vaadin/framework/issues/11416 calls navigateTo allways when Navigator is present, which is wrong, since it is needed only when navigation state has truly changed.
* Add test to the fix
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/UI.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java index 682e1f38f2..2a3b913e16 100644 --- a/server/src/main/java/com/vaadin/ui/UI.java +++ b/server/src/main/java/com/vaadin/ui/UI.java @@ -162,6 +162,12 @@ public abstract class UI extends AbstractSingleComponentContainer this); /** + * Holder for old navigation state, needed in doRefresh in order not to call + * navigateTo too often + */ + private String oldNavigationState; + + /** * Scroll Y position. */ private int scrollTop = 0; @@ -871,10 +877,15 @@ public abstract class UI extends AbstractSingleComponentContainer page.updateBrowserWindowSize(newWidth, newHeight, true); // Navigate if there is navigator, this is needed in case of - // PushStateNavigation + // PushStateNavigation. Call navigateTo only if state have + // truly changed Navigator navigator = getNavigator(); if (navigator != null) { - navigator.navigateTo(navigator.getState()); + if (oldNavigationState == null) oldNavigationState = getNavigator().getState(); + if (!navigator.getState().equals(oldNavigationState)) { + navigator.navigateTo(navigator.getState()); + oldNavigationState = navigator.getState(); + } } } |