Skip to content

Commit 751278a

Browse files
authored
fix: Do not fail component picking if Flow is undefined (#15740)
1 parent ab54335 commit 751278a

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

vaadin-dev-server/src/main/resources/META-INF/frontend/component-picker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export class ComponentPicker extends LitElement {
139139

140140
pickSelectedComponent() {
141141
const component = this.components[this.selected];
142+
if (!component) {
143+
this.abort();
144+
return;
145+
}
142146
this.dispatchEvent(
143147
new CustomEvent('component-picker-pick', {
144148
detail: { component: { nodeId: component.nodeId, uiId: component.uiId } }

vaadin-dev-server/src/main/resources/META-INF/frontend/component-util.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ export function getComponents(element: HTMLElement): ComponentReference[] {
2222
}
2323

2424
function getComponent(element: HTMLElement): ComponentReference {
25-
const { clients } = (window as any).Vaadin.Flow;
26-
const appIds = Object.keys(clients);
27-
for (const appId of appIds) {
28-
const client = clients[appId];
29-
if (client.getNodeId) {
30-
const nodeId = client.getNodeId(element);
31-
if (nodeId >= 0) {
32-
return { nodeId, uiId: client.getUIId(), element };
25+
const vaadin = (window as any).Vaadin;
26+
if (vaadin && vaadin.Flow) {
27+
const { clients } = vaadin.Flow;
28+
const appIds = Object.keys(clients);
29+
for (const appId of appIds) {
30+
const client = clients[appId];
31+
if (client.getNodeId) {
32+
const nodeId = client.getNodeId(element);
33+
if (nodeId >= 0) {
34+
return { nodeId, uiId: client.getUIId(), element };
35+
}
3336
}
3437
}
3538
}

0 commit comments

Comments
 (0)