flow icon indicating copy to clipboard operation
flow copied to clipboard

Incorrect page titles in browser history

Open igormilina opened this issue 1 year ago • 0 comments

Description of the bug

In vaadin Flow, browser history entries have incorrect page titles. Browser history is available by clicking and holding "Back" button in browser - after 2 seconds, a list of history will be shown.

So if we open application and execute navigation, for example: View1 --> View2 --> View3 browser history should have entries with titles:

  • View2
  • View1

Which would be correct, as View2 (the last entry) is previous view. Currently, browser history in this example does have 2 entries - but they have incorect titles:

  • View3
  • View2

Which is wrong, since View3 is current applicaton view, and should not appear in the history. But, clicking "back" in browser will navigate back to View2, which is correct behaviour, so only page titles are broken.

It seems like when navigationg, the applicaion is setting the title of the new view too early, so the browser is adding history entry with the new title, instead of the current one.

This issue was not present in 14.8.1. I've noticed the problem while migrating project to 23.1.3.

Expected behavior

If we open application and execute navigation, for example: View1 --> View2 --> View3 browser history should have entries with titles:

  • View2
  • View1

(browser history is available by clicking and holding "Back" button in browser - after 2 seconds, a list of history will be shown)

Minimal reproducible example

  • Go to https://start.vaadin.com/app, create an application and run it.
  • Open application in browser: http://localhost:8080/. HelloWorldView is shown with page title "Hello world"
  • Click "About" link. AboutView is shown with page title "About"
  • Now click and hold "Back" button in browser - after 2 seconds, a list of history will be shown. The latest entry, which is previous page, has titile "About", but should have title "Hello world" as this is the correct title of the previous view. Clicking this entry will open hello world as expected.

Versions

  • Vaadin / Flow version: 23.1.3, 23.1.4
  • Java version: 11
  • OS version: Win10
  • Browser version (if applicable): Chrome 103 and Edge 103, but the issue does not seems to be browser dependent
  • Application Server (if applicable): Tomcat 9
  • IDE (if applicable): the issue does not seems to be IDE dependent

igormilina avatar Aug 03 '22 08:08 igormilina