Ui.getCurrent().navigate() does not change Browser URL

Hi. After upgrading from 24.4.12 to 24.5.4 i have the problem, that the Browser URL does not change when UI.getCurrent().navigate() is called. The content and page title are set but the url stays the same.
Eg. i am currently on a view with route “/alldashboards”. There is a grid and on item click UI.getCurrent().navigate(“dashboard/” + item.getId()) is called. Navigation itself seems to work, since title and content are set, but the url stays “/alldashboards”.

Would it be possible to use anchors (or router links) instead?

There should not be this kind of regressions, let’s get it fixed instead of try to find workarounds. I quickly tried to reproduce, but I could not. This might be related to the “react router”, there has been some.

Could you post a minimal project where issue can be reproduced?

2 Likes

First, thanks for the answers! Disabling the react router in the application properties did in fact solve the problem. We had the problem with any call of navigate(). Calling navigateToClient() instead worked fine, but since this needs a lot of code changes, we stick with disabling the react router.

I’ve made a ticket in Vaadin Flow Ui.getCurrent().navigate() does not change Browser URL · Issue #20478 · vaadin/flow · GitHub.
If possible, please provide a minimal reproducible example to us.

Cannot reproduce with react router enabled and the following sample code.

@Route("alldashboards")
@AnonymousAllowed
public class AllDashboards extends VerticalLayout {

    public AllDashboards() {

        Grid<Integer> grid = new Grid<>();
        grid.addColumn(id -> "Dashboard " + id).setHeader("ID");
        grid.addItemClickListener(ev -> {
            UI.getCurrent().navigate("dashboard/" + ev.getItem());
        });
        grid.setItems(IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toList()));
        add(grid);
    }
}
@Route("dashboard")
public class Dashboard extends Div implements HasUrlParameter<Integer> {

    private final Span text = new Span();

    public Dashboard() {
        add(text);
        add(new RouterLink("All dashboards", AllDashboards.class));
    }

    @Override
    public void setParameter(BeforeEvent beforeEvent, Integer integer) {
        text.setText("Welcome to dashboard " + integer.toString());
    }
}

Can you please provide an example project or the steps to reproduce the issue?
Did your application use a custom dev-bundle? If so, did you try to delete the content of src/main/bundles after upgrading Vaadin version?