Skip to content

Commit 4be0159

Browse files
committed
fix: components tree flashing
1 parent c03e25d commit 4be0159

File tree

1 file changed

+23
-4
lines changed
  • packages/app-frontend/src/features/components

1 file changed

+23
-4
lines changed

packages/app-frontend/src/features/components/index.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,8 @@ export function setupComponentsBridgeEvents (bridge) {
248248
const instance = componentsMap[instanceId]
249249
if (instance) {
250250
for (const item of data) {
251-
const component = componentsMap[item.id]
252-
for (const key in item) {
253-
Vue.set(component, key, item[key])
254-
}
251+
restoreChildrenFromComponentsMap(item)
252+
const component = updateComponentsMapData(item)
255253
addToComponentsMap(component)
256254
}
257255
} else if (Array.isArray(data)) {
@@ -300,6 +298,27 @@ function requestComponentTree (instanceId = null) {
300298
})
301299
}
302300

301+
function restoreChildrenFromComponentsMap (data) {
302+
const instance = componentsMap[data.id]
303+
if (instance && data.hasChildren) {
304+
if (!data.children.length && instance.children.length) {
305+
data.children = instance.children
306+
} else {
307+
for (const child of data.children) {
308+
restoreChildrenFromComponentsMap(child)
309+
}
310+
}
311+
}
312+
}
313+
314+
function updateComponentsMapData (data) {
315+
const component = componentsMap[data.id]
316+
for (const key in data) {
317+
Vue.set(component, key, data[key])
318+
}
319+
return component
320+
}
321+
303322
function addToComponentsMap (instance) {
304323
componentsMap[instance.id] = instance
305324
if (instance.children) {

0 commit comments

Comments
 (0)