Skip to content

Commit 2ba5d4f

Browse files
vaadin-botcaalador
andauthored
fix: reload flow after hmr reload in dev mode (#19323) (#19348)
Reset and reload flow when a template hrm reload happens. Fixes #19291 Co-authored-by: caalador <mikael.grankvist@vaadin.com>
1 parent 514fe0b commit 2ba5d4f

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

‎flow-client/src/main/frontend/FlowBootstrap.js‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,36 @@ Please submit an issue to https://github.com/vaadin/flow-components/issues/new/c
9090
throw new Error('Application ' + appId + ' is already being initialized');
9191
}
9292
if (isInitializedInDom(appId)) {
93-
throw new Error('Application ' + appId + ' already initialized');
93+
if (appInitResponse.appConfig.productionMode) {
94+
throw new Error('Application ' + appId + ' already initialized');
95+
}
96+
97+
// Remove old contents for Flow
98+
var appDiv = document.getElementById(appId);
99+
for (var i = 0; i < appDiv.childElementCount; i++) {
100+
appDiv.childNodes[i].remove();
101+
}
102+
103+
// For devMode reset app config and restart widgetset as client
104+
// is up and running after hrm update.
105+
const getConfig = function (name) {
106+
return config[name];
107+
};
108+
109+
/* Export public data */
110+
const app = {
111+
getConfig: getConfig
112+
};
113+
apps[appId] = app;
114+
115+
if (widgetsets['client'].callback) {
116+
log('Starting from bootstrap', appId);
117+
widgetsets['client'].callback(appId);
118+
} else {
119+
log('Setting pending startup', appId);
120+
widgetsets['client'].pendingApps.push(appId);
121+
}
122+
return apps[appId];
94123
}
95124
}
96125

0 commit comments

Comments
 (0)