Flow: RouterLink click issue after programmatic navigation

Created on 3 Jul 2020  路  14Comments  路  Source: vaadin/flow

If from /users I navigate to /users/123 with

UI.getCurrent().navigate(Users.class, id);

then if I click on a RouterLink to /users nothing happens.

High Major bug

All 14 comments

I reproduced the same problem with version 16.0.0 after building an application in production mode. There is no issue on Dev mode.

Thank you, @heruan and @jmycka for the ticket. We are looking into this issue.

I am unable to reproduce this problem on Vaadin 16 and 17 (in neither development nor production mode) with a simple project containing the following view:

@Route("users")
public class UsersView extends VerticalLayout implements HasUrlParameter<Integer> {
    public UsersView() {
        add(new RouterLink("Routerlink to users",  UsersView.class));
        add(new Button("Programmatically to users/123", e -> UI.getCurrent().navigate(UsersView.class, 123)));
    }

    @Override
    public void setParameter(BeforeEvent event, @OptionalParameter Integer parameter) {
        System.out.println("Got parameter " + parameter);
    }
}

Please provide code context and ideally a small project that exposes the problem.

This is duplicate of 8575, and it is reproducible in Vaadin 16, haven't tried in V17. It is important to note that the problem happens when navigating back to the original route.

@igormilina Thanks for the ticket and description, this is now clear and reproducible with Vaadin 16. It should be fixed with @vaadin/router version 1.7.2 (see 8071). To confirm this, you can try a Vaadin 17 prerelease (which includes the updated @vaadin/router)

Will this be available in V16? Unfortunately V17 brings breaking changes on the data-provider API which prevent us to update right now.

@heruan Yes, the next maintenance release of Vaadin 16 (16.0.2, didn't get into 16.0.1) will include the updated @vaadin/router dependency. As a workaround, you can until then use npm mode (instead of pnpm) or pin the version of @vaadin/router in pnpmfile.js (there is an example there of forcing chokidar version).

@joheriks Not sure why, but I already see "@vaadin/router": "1.7.2" in my package.json with V16 馃

Despite that, I still get 1.7.1 in node_modules even pinning in pnpmfile.js, i.e.

  if (pkg.dependencies['@vaadin/router']) {
    pkg.dependencies['@vaadin/router'] = '^1.7.2';
  }

Hi @heruan, I think it's because in v16, pnpm is used by default, and it's reading the version from versions.json file. I've made a fix yesterday, now waiting for another maintenance release.

I think the pnpmfile.js is overridden automatically every time you start the application.

So I think you can try to delete the node_modules and target folder, and then run the application with npm mode, in this way, you should be able to get the 1.7.2 version of @vaadin/router.

Thanks, not sure what I'm missing but I've tried both Spring's vaadin.pnpm.enable = false and POM's plugin configuration <pnpmEnable>false</pnpmEnable> but I still get PNPM 馃槙

Either of these should work for switching to npm. If you use pnpmEnable to set in the mode in the configuration section of vaadin-maven-plugin (in the profile for development mode), can you verify that target/classes/META-INF/VAADIN/config/flow-build-info.json contains a line "pnpm.enable": false?

I'd probably missed a clean, now I'm on NPM and 1.7.2 showed up.

Does it work with npm, can we close the ticket? @heruan

It didn't happen yet with Router 1.7.2, I'll close this for now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pleku picture pleku  路  4Comments

rucko24 picture rucko24  路  3Comments

pleku picture pleku  路  4Comments

marcushellberg picture marcushellberg  路  4Comments

manolo picture manolo  路  3Comments