Skip to content

Commit 4306e29

Browse files
authored
fix: use window name to detect presence of extended client details (#493)
RouteScope logic behave differently if extended client details have been fetched or not. The current check is to verify if the instance is null, but since vaadin/flow#22719 UIInternal.getExtendedClientDetail never returns null. This change updates the logic to check instead for ExtendedClientDetail.windowName that is always sent by Flow client when the details are fetched.
1 parent 5ea90d6 commit 4306e29

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

vaadin-cdi/src/main/java/com/vaadin/cdi/context/RouteScopedContext.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,14 @@ private UI findPreservingUI(UI ui) {
126126
}
127127

128128
private static String getWindowName(UI ui) {
129-
ExtendedClientDetails details = ui.getInternals()
130-
.getExtendedClientDetails();
131-
if (details == null) {
132-
return null;
133-
}
129+
ExtendedClientDetails details = ui.getInternals().getExtendedClientDetails();
134130
return details.getWindowName();
135131
}
136132

137133
private RouteStorageKey getKey(UI ui, Class<?> owner) {
138-
ExtendedClientDetails details = ui.getInternals()
139-
.getExtendedClientDetails();
134+
ExtendedClientDetails details = ui.getInternals().getExtendedClientDetails();
140135
RouteStorageKey key = new RouteStorageKey(owner, getUIStoreId(ui));
141-
if (details == null) {
136+
if (details.getWindowName() == null) {
142137
ui.getPage().retrieveExtendedClientDetails(
143138
det -> relocate(ui, key));
144139
}
@@ -158,9 +153,8 @@ private List<ContextualStorage> getActiveContextualStorages() {
158153
}
159154

160155
private String getUIStoreId(UI ui) {
161-
ExtendedClientDetails details = ui.getInternals()
162-
.getExtendedClientDetails();
163-
if (details == null) {
156+
ExtendedClientDetails details = ui.getInternals().getExtendedClientDetails();
157+
if (details.getWindowName() == null) {
164158
return "uid-" + ui.getUIId();
165159
} else {
166160
return "win-" + getWindowName(ui);

0 commit comments

Comments
 (0)