Skip to content

Legacy URL fragment lost after refresh #127

@paodb

Description

@paodb

This is related to #123

Setup: MPR (Vaadin 23.3.13/7.7.38) with MprNavigatorRoute and Spring-boot with servlet mapping configuration.

Description: When trying to navigate to a legacy view after refresh (F5) the target url reverts to the default one.

Example:

MprNavigatorRoute implementation:

import com.vaadin.flow.router.Route;
import com.vaadin.mpr.MprNavigatorRoute;
import com.vaadin.navigator.Navigator;

@Route("bo")
public class MyNavigatorRoute extends MprNavigatorRoute {
	@Override
	public void configureNavigator(Navigator navigator) {
		navigator.addView("", HomeView.class);
		navigator.addView("view1", View1.class);
		navigator.addView("view2", View2.class);
	}
}

HomeView:

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;

public class HomeView extends VerticalLayout implements View {

	public HomeView() {
		addComponent(new Button("Navigate to view 1", ev -> {
			getUI().getNavigator().navigateTo("view1");
		}));
		
		addComponent(new Button("Navigate to view 2", ev -> {
			getUI().getNavigator().navigateTo("view2");
		}));
	}

	@Override
	  public void enter(ViewChangeEvent event) {}
}

View1:

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;

public class View1 extends VerticalLayout implements View {

  public View1() {
    setCaption("View 1");

    addComponent(new Button("Navigate to view 2", ev -> {
      getUI().getNavigator().navigateTo("view2");
    }));
  }
  
  @Override
  public void enter(ViewChangeEvent event) {}
 
}

View2:

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;

public class View2 extends VerticalLayout implements View {

  public View2() {
    setCaption("View 2");
    addComponent(new Button("Navigate to view 1", ev -> {
        getUI().getNavigator().navigateTo("view1");
      }));

  }

  @Override
  public void enter(ViewChangeEvent event) {}
}

aplication.properties:
vaadin.urlMapping=/app/*

Or here's the zip with the sample application:
MPR-7-23-Refresh.zip

Steps to reproduce:
1 - Go to http://localhost:8080/app/bo
2 - Click on "Navigate to v1" to go to View1
3 - When on View1, check that URL is http://localhost:8080/app/bo#!view1 and press F5 Key for refresh
4 - After refresh, click on "Navigate to v2" to go to View2

Expected behavior:
When navigating to View2 after pressing F5, URL should be http://localhost:8080/app/bo#!view2

Actual behavior:
When navigating to View2 after pressing F5, URL should be http://localhost:8080/app/bo#!view2 but it's reverted to http://localhost:8080/app/bo

If refresh is not done, navigation works okay.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions