Skip to content

Navigation problem when ClickShortcut is present in LegacyWrapper #115

Closed
vaadin/flow
#14397

Description

@paodb

Description

Navigation seems to break when trying to navigate to a Flow View containing a LegacyWrapper of a Vaadin 7 component. The issue seems to be caused when adding a ClickShortcut to a Vaadin 7 Button that is inside a Legacy Wrapper in a Vaadin Flow View. If I remove that ClickShortcut, the navigation works okay. See attached image of the problem:

mpr_navigation1

Minimal reproducible example

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;

@Route(value = "navigate")
public class NavigatePage extends VerticalLayout {

    public NavigatePage() {
        Button button = new Button("Navigate", event -> {
            event.getSource().getUI().ifPresent(ui -> ui.navigate("button"));
        });

        add(button);
    }
}
import com.vaadin.event.ShortcutAction;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
import com.vaadin.mpr.LegacyWrapper;
import com.vaadin.ui.Button;

@Route(value = "button")
public class ButtonPage extends VerticalLayout {

    public ButtonPage() {
        Button button = new Button("Vaadin 7 Button");
        button.setClickShortcut(ShortcutAction.KeyCode.ENTER); // comment to make it work

        add(new LegacyWrapper(button));
    }
}

Complete example here: mpr_navigation_sources.zip

Versions

  • Vaadin Framework: 7.7.32
  • Flow: 23.1.3
  • MPR: 6.0.1
  • Java JRE / JDK: 11

Activity

  1. MarcinVaadin commented on Aug 5, 2022

    @MarcinVaadin

    Investigation results:

    Why going root -> Button or navigate -> Button does not brake the location? Because:

    1. Framework UI is being lazely loaded when opening view with v7 component
    2. Current location is stored in v7 Page object
    3. Two UIDL updates are returned, one for Flow (no dirty v7 components for state update yet) and one after Framework initialization

    And why going back and forth is breaking location:

    1. Adding clickShortcut is causing MprUI to be marked as dirty
    2. Dirty visible components state is added to UIDL to force component repaint
    3. MprUI state contains location from Page instance (see point 2 from list above)
    4. Vaadin 23 UidlRequestHandler.removeOffendingMprHashFragment is looking for location and forces unnecessary history state push (with previously stored improper location) - (introduced in fix path when full location is provided flow#7693)
  2. self-assigned this
    on Aug 9, 2022
  3. mshabarov commented on Aug 16, 2022

    @mshabarov

    Indeed, this is a regression after applying a patch for fixing vaadin/flow#7540 .

    UidlRequestHandler::removeOffendingMprHashFragment adds an extra http://localhost:8080 to the history, through this method:
    https://github.com/vaadin/flow/blob/020ee677e59d3b0f411232e402c55a68f34924f2/flow-server/src/main/java/com/vaadin/flow/server/communication/UidlRequestHandler.java#L309

    The navigation works well if the server-side bootstrapping is turned on through the parameter vaadin.useDeprecatedV14Bootstrapping=true in application.properties. In server-side bootstrapping mode the fragment manipulations are disabled. This can be used as a workaround until the issue is fixed.

  4. kshashov commented on Aug 16, 2022

    @kshashov

    We tried turning useDeprecatedV14Bootstrapping on but the issue was still reproducible in a slightly different way
    mpr_navigation2

  5. mshabarov commented on Aug 17, 2022

    @mshabarov

    @kshashov thanks, indeed, this also doesn't fix the problem. Looks like a completely different issue in Flow vaadin/flow#14323 .

  6. added a commit that references this issue on Aug 22, 2022
    451f7ef
  7. added 3 commits that reference this issue on Aug 22, 2022
    b260454
    bfd0128
    c0cfbbe
  8. added 3 commits that reference this issue on Aug 22, 2022
    21e6ea7
    2aa03eb
    f31cf9a
  9. Tostino commented on Aug 22, 2022

    @Tostino

    Looking for guidance on when the next hotfix release will be that will include this, or the best way to incorporate this just this fix into our build, as we need to get our software released very soon and are looking for the path that gives us the least resistance here.

  10. mshabarov commented on Aug 22, 2022

    @mshabarov

    @Tostino which version of Vaadin do you use? Is it V23.1.x ? Since the fix is on the Flow side, I can release the corresponding version of Flow with this patch tomorrow morning and you can override it in your project. Platform release comes later on according to a normal schedule, so once it's ready you would remove the override and just upgrade the platform version. Does it sound fine for you?

  11. Tostino commented on Aug 22, 2022

    @Tostino

    We made the original report, so we are on 23.1.3 right now. That seems like it'll work just fine, we can just upgrade the flow version.

    Thanks for the help here.

  12. mshabarov commented on Aug 23, 2022

    @mshabarov

    @Tostino please try a new Flow 23.1.6 with this patch:

        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>flow-bom</artifactId>
                    <version>23.1.6</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-bom</artifactId>
                    <type>pom</type>
                    <scope>import</scope>
                    <version>23.1.6</version>
                </dependency>
            </dependencies>
        </dependencyManagement>
    

    Will be included into next 23.1.x platform release.

  13. vaadin-bot commented on Sep 9, 2022

    @vaadin-bot

    This ticket/PR has been released with Vaadin 23.1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions