Navigation issue after upgrading from Vaadin 14.2.0 to 14.2.1

Hello!

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.

The same problem occurs using Vaadin 16 and 17.

Only 14.2.0 is working for me.

What I have got to do?

Thank you very much,
Thomas

Can you create a small sample project that reproduces the issue? If yes, you should report a issue in GitHub: https://github.com/vaadin/flow/issues/new

Hello Olli!

Small sample project is very difficult for me.

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.

I think the change was build with https://github.com/vaadin/flow/pull/8365.

Thank you very much for your help.

Thomas

I guess you should create a ticket regardless, then. But a sample will definitely help in getting it fixed.

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

Hello!

I think that the problem came with

flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java

https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java

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.

Thank you very much for your help,
Thomas

Hello!

I think that the problem came with

flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java

https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/router/internal/AbstractNavigationStateRenderer.java

https://github.com/vaadin/flow/commit/79ff40505f99d22d93c287d8f7559f379c810720

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.

Thank you very much for your help,
Thomas

Dear Vaadin Team, did you realize the problem?

Thomas Kohler:
Dear Vaadin Team, did you realize the problem?

Hello Thomas K!

I placed an issue here: https://github.com/vaadin/flow/issues/8605

My sample reproduces the error (I guess). But now I have to create a smaller sample for the Vaadin team.

Do you have a small sample to reproduce the error?

Greetings from Braunschweig, Germany
Thomas

I also have problem with navigation in 14.2.1.

ui.getUI().ifPresent(uii -> {
uii.navigate(View.class, data);
});

if above code is called outside an event listener (as button listener), then GUI will not update.

Olli Tietäväinen:
I guess you should create a ticket regardless, then. But a sample will definitely help in getting it fixed.

Hello Olli!

Thank you very much for your answer. I created a ticket with a small sample project.

Kind regards, Thomas

Olli Tietäväinen:
I guess you should create a ticket regardless, then. But a sample will definitely help in getting it fixed.

Hello Olli!

Thank you very much for your answer. I created a ticket with a small sample project.

Kind regards, Thomas

Thomas Niedergesaess:

Olli Tietäväinen:
I guess you should create a ticket regardless, then. But a sample will definitely help in getting it fixed.

Hello Olli!

Thank you very much for your answer. I created a ticket with a small sample project.

Kind regards, Thomas

Great, thanks!

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.

Regards, Tom

Hello Vaadin team!

Great job. 14.2.3 is working with @PreserveOnRefresh. But there seems to be another error.

14.2.0 worked for me.

14.2.3 is working but there is a new JavaScript-Error: “Assertion error: No child node found with id 4”.

After a fallback to 14.2.0 there is no assertion error anymore.

Do you have an idea what to do?

Thank you very much for your help,
Thomas

18339594.png