I am using Vaadin 14.2.0 with @com.vaadin.flow.router.PreserveOnRefresh.
Now I am navigation to one of my views and the framework calls
@Override
public void setParameter(final com.vaadin.flow.router.BeforeEvent newEvent,
@com.vaadin.flow.router.WildcardParameter final java.lang.String newParameter) {
Using 14.2.0 works fine the function setParameter ist called once a time during navigation.
Also browser refresh is working very well.
Now I am upgrading to 14.2.1 - the issue occurs. The function setParameter is called two times during navigation and the gui flickers. Why it is called two times?
If I uncommend PreserveOnRefresh all is fine but browser refresh does not work anymore.
14.2.0 is working goood with @com.vaadin.flow.router.PreserveOnRefresh.
14.2.1 is not working with @com.vaadin.flow.router.PreserveOnRefresh - but without.
17.0.0.alpha4 is working goood with @com.vaadin.flow.router.PreserveOnRefresh.
Same Problem here, we are using @PreserveOnRefresh on Layout and below, when e.g. switching between Routes in NaviDrawer (Business Example) and clicking a second time to the route, a new get request is done by the browser. Third, Fourth, … click (on same Route) don’t force a get request. Switching back to 14.2.0 fixes the Problem.
Tom
Line 790 seems to be the problem: “prevUi.close();”
// Transfer all remaining UI child elements (typically dialogs
// and notifications) to the new UI
maybePrevUI.ifPresent(prevUi -> {
ui.getInternals().moveElementsFrom(prevUi);
prevUi.close();
});
My ui is de.thomas.MyClass.
A lot of RouterLinks are directing to de.thomas.MyClass (UI 1, UI 2, UI 3).
UI 1 with URL parameter “my-parameter=1”.
UI 2 with URL parameter “my-parameter=2”.
UI 3 with URL parameter “my-parameter=3”.
I am showing UI 1 for the first time - all is OK.
I put a break point in
public void setParameter(final com.vaadin.flow.router.BeforeEvent newEvent,
@com.vaadin.flow.router.WildcardParameter final java.lang.String newParameter) {
There I see my expected paramter “my-parameter=1”.
Now I am showing UI 2 (following the RouterLink). An then it becomes very strange.
It stops 2 times in the method “setParameter” (url parameters are ok “my-parameter=2”). The ui is shown 2 times and the ui flickers. Also I put a break point in line 790 of class “AbstractNavigationStateRenderer”. There it stops 2 times too.
I think line 790 is the problem. 790 came with Vaadin 14.2.1 - 14.2.0 ist working.
Line 790 seems to be the problem: “prevUi.close();”
// Transfer all remaining UI child elements (typically dialogs
// and notifications) to the new UI
maybePrevUI.ifPresent(prevUi -> {
ui.getInternals().moveElementsFrom(prevUi);
prevUi.close();
});
My ui is de.thomas.MyClass.
A lot of RouterLinks are directing to de.thomas.MyClass (UI 1, UI 2, UI 3).
UI 1 with URL parameter “my-parameter=1”.
UI 2 with URL parameter “my-parameter=2”.
UI 3 with URL parameter “my-parameter=3”.
I am showing UI 1 for the first time - all is OK.
I put a break point in
public void setParameter(final com.vaadin.flow.router.BeforeEvent newEvent,
@com.vaadin.flow.router.WildcardParameter final java.lang.String newParameter) {
There I see my expected paramter “my-parameter=1”.
Now I am showing UI 2 (following the RouterLink). An then it becomes very strange.
It stops 2 times in the method “setParameter” (url parameters are ok “my-parameter=2”). The ui is shown 2 times and the ui flickers. Also I put a break point in line 790 of class “AbstractNavigationStateRenderer”. There it stops 2 times too.
I think line 790 is the problem. 790 came with Vaadin 14.2.1 - 14.2.0 ist working.
An easy sample is also your BusinessLayout. Just install the BusinessLayout sample app together with 14.2.1 or 14.2.2 (both versions have the problem) and add @PreserveOnRefresh to the MainLayout class.
To see the Problem just switch between two different Routes in the NaviDrawer and then click AGAIN a second time on the last selected Route. This triggers a new GET request (and therefore a new UI), clicking then a THIRD time (ore more) again on the same Route in the NaviDrawer behaves correct. Switching between two different routes behaves correct, unless you click again on the last Route…
I’ll attach a short ScreenVideo where it is possible to see the described behaviour.