flow
flow copied to clipboard
Page title construction in RouterLayout issue
Description of the bug
After these changes in Vaadin Flow
https://github.com/vaadin/flow/pull/13825/files#diff-32470b1fe06ff7a0966c7da3ded43f636d1a013b78ff34b06049c7915c4c359cR238
It's not possible to construct custom page title outside of each view. Navigation lifecycle always rewrites title at the end, so it seems that there is no places left where we can call Page.setTitle("custom title")
.
Expected behavior
It's must be possible to set custom page title after navigation finished
Minimal reproducible example
Minimal example from the real app: https://github.com/gigi/vaadin-23-pagetitle-issue
Main idea is to avoid service dependencies coupling and delegate control of common UI elements to layouts.
So there is custom PageChangedEvent event which can be used for updating layout menu, breadcrumbs construction, setting page title etc. This event is fired in After Navigation stage. Before these changes it was possible to construct page title and set it by hand: https://github.com/gigi/vaadin-23-pagetitle-issue/blob/main/src/main/java/com/example/demo/layout/BasicLayout.java#L50
Possible solutions:
- Add support of
HasDynamicTitle
in the RouterLayout that has higher priority than Router'sgetPageTitle
or vice versa - Concatenate page title somewhere in response listeners (I don't know where exactly and how to handle title template properly)
- Inject necessary layout dependencies in each view and construct title in
getPageTitle
(quite annoying)
Versions
- Vaadin: 23.1.0.rc1
- Flow: 23.1.0.rc2
- Java: BellSoft 17.0.3
- OS: x86_64 Mac OS X 12.3.1
- Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36