Skip to content

Conversation

@heruan
Copy link
Member

@heruan heruan commented Dec 11, 2025

This pull request enhances the handling of page titles for views annotated with @PreserveOnRefresh in Vaadin applications. The main improvement is ensuring that when a view's title is updated at runtime, the new title is correctly preserved and restored after a browser refresh. This is achieved by extending the preserved view state to include the page title, updating it when necessary, and adding new tests to verify the behavior.

Preserved View Title Handling:

  • Extended the preserved view state (PreservedViewData) to store the page title alongside the view chain and location, replacing the previous use of Pair. [1] [2]
  • Updated the logic in AbstractNavigationStateRenderer so that when a preserved view is restored after refresh, its title is also restored if available.
  • Added a new method, updatePreservedChainTitle, to update the preserved title in the session when the UI title changes, and invoked this method from UIInternals.setTitle. [1] [2]
  • Improved the page title update logic to avoid overwriting a preserved title during refresh if the view does not provide a dynamic title.

Testing and Validation:

  • Added a new test view (PreserveOnRefreshTitleView) and integration test (PreserveOnRefreshTitleIT) to verify that title updates are preserved across browser refreshes for views with @PreserveOnRefresh. [1] [2]
  • Updated existing unit tests to use the new setPreservedChain signature with title support and to validate the correct restoration and purging of preserved chains. [1] [2] [3] [4] [5]

These changes ensure a consistent and expected user experience when navigating and refreshing pages with preserved views.

Fixes #22201

🤖 Created with Claude

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

Test Results

1 309 files  + 1  1 309 suites  +1   1h 16m 48s ⏱️ + 1m 9s
9 194 tests + 1  9 126 ✅ + 1  68 💤 ±0  0 ❌ ±0 
9 653 runs  +10  9 577 ✅ +10  76 💤 ±0  0 ❌ ±0 

Results for commit fa89aaa. ± Comparison against base commit 733d8bf.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link

Copy link
Member Author

@heruan heruan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not really address the original issue: it does indeed preserve a programmatically set title when refreshing the page, but it does not prevent the title to be cleared when it's only set by AppShellConfigurator. Consider closing or re-work from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Page title set by AppShellConfigurator cleared on reload

2 participants