Skip to content

fix: prevent duplicated history entry with vaadin-router #21305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

mcollovati
Copy link
Collaborator

When using legacy vaadin-router, browser history for client-side navigation is updated by the router itself when navigation completes. However, in some situations the history gets updated also by the server side, causing two history entries for the same navigation and consequently a wrong behavior if pressing the browser back button.

This change:

  • Prevents updating history on the server side, unless the server is handling a postponed navigation for which vaadin-router does not update the history
  • Adds a test module for vaadin-router with the most common navigation tests
  • Re-enables several tests that are now passing, likely because previous changes fixed the related issues

Fixes #21243
Fixes #19494
Fixes vaadin/hilla#335

When using legacy vaadin-router, browser history for client side navigation is
updated by the router itself when navigation completes. However, in some
situations the history gets updated also by the server side, causing two
history entries for the same navigation and consequently a wrong behavior if
pressing browser back button.

This change:
- Prevents updating history on the server side, unless the server is handling
  a postponed navigation for which vaadin-router does not update the history
- Adds a test module for vaadin-router with the most common navigation tests
- Re-enables several tests that are now passing, likely because previous
  changes fixed the related issues

Fixes #21243
Fixes #19494
Fixes vaadin/hilla#335
Copy link

github-actions bot commented Apr 16, 2025

Test Results

1 214 files  + 22  1 214 suites  +22   1h 20m 27s ⏱️ + 1m 24s
8 352 tests + 36  8 296 ✅ + 37  56 💤  - 1  0 ❌ ±0 
8 759 runs  +105  8 694 ✅ +105  65 💤 ±0  0 ❌ ±0 

Results for commit 2479d3e. ± Comparison against base commit 4a2e749.

This pull request removes 2 and adds 38 tests. Note that renamed tests count towards both.
com.vaadin.flow.BackNavIT ‑ testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.BackNavIT(production) ‑ testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.AddQueryParamIT ‑ validateRouterInUse[any_Chrome_]
com.vaadin.flow.AddQueryParamIT(production) ‑ validateRouterInUse[any_Chrome_]
com.vaadin.flow.BackNavIT ‑ routerLinkNavigation_testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.BackNavIT ‑ serverSideNavigation_testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.BackNavIT(production) ‑ routerLinkNavigation_testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.BackNavIT(production) ‑ serverSideNavigation_testBackButtonAfterHistoryStateChange[any_Chrome_]
com.vaadin.flow.HistoryIT ‑ testHistory[any_Chrome_]
com.vaadin.flow.HistoryIT(production) ‑ testHistory[any_Chrome_]
com.vaadin.flow.NavigationEventsIT ‑ assertNavigationToSelfProducesNavigationEvents[any_Chrome_]
com.vaadin.flow.NavigationEventsIT(production) ‑ assertNavigationToSelfProducesNavigationEvents[any_Chrome_]
…

♻️ This comment has been updated with latest results.

@caalador caalador merged commit ba644ca into main Apr 22, 2025
27 checks passed
@caalador caalador deleted the issues/21243-vaadin_router_back_navigation branch April 22, 2025 07:24
vaadin-bot pushed a commit that referenced this pull request Apr 22, 2025
When using legacy vaadin-router, browser history for client side navigation is
updated by the router itself when navigation completes. However, in some
situations the history gets updated also by the server side, causing two
history entries for the same navigation and consequently a wrong behavior if
pressing browser back button.

This change:
- Prevents updating history on the server side, unless the server is handling
  a postponed navigation for which vaadin-router does not update the history
- Adds a test module for vaadin-router with the most common navigation tests
- Re-enables several tests that are now passing, likely because previous
  changes fixed the related issues

Fixes #21243
Fixes #19494
Fixes vaadin/hilla#335
vaadin-bot added a commit that referenced this pull request Apr 22, 2025
…: 24.7) (#21319)

* fix: prevent duplicated history entry with vaadin-router (#21305)

When using legacy vaadin-router, browser history for client side navigation is
updated by the router itself when navigation completes. However, in some
situations the history gets updated also by the server side, causing two
history entries for the same navigation and consequently a wrong behavior if
pressing browser back button.

This change:
- Prevents updating history on the server side, unless the server is handling
  a postponed navigation for which vaadin-router does not update the history
- Adds a test module for vaadin-router with the most common navigation tests
- Re-enables several tests that are now passing, likely because previous
  changes fixed the related issues

Fixes #21243
Fixes #19494
Fixes vaadin/hilla#335

* Fix module parent pom version

---------

Co-authored-by: Marco Collovati <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants