Skip to content

Commit 550adfe

Browse files
committed
add dispatch
1 parent cdb9fb9 commit 550adfe

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

client/packages/lowcoder/src/comps/comps/navComp/components/MenuItemList.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,9 @@ export function menuPropertyView(itemsComp: NavListCompType) {
244244

245245
const newJson = buildJsonFromTree(newItems);
246246

247-
// Clear all existing items and re-add in new order
248-
const currentLength = itemsComp.getView().length;
249-
250-
// Delete all items from end to start
251-
for (let i = currentLength - 1; i >= 0; i--) {
252-
itemsComp.deleteItem(i);
253-
}
254-
255-
// Add items back in new order
256-
newJson.forEach((itemJson) => {
257-
itemsComp.addItem(itemJson);
258-
});
247+
// Use setChildrensAction for atomic update instead of delete-all/add-all
248+
// This is more efficient and prevents UI glitches from multiple re-renders
249+
itemsComp.dispatch(itemsComp.setChildrensAction(newJson));
259250
};
260251

261252
return controlItem(

0 commit comments

Comments
 (0)