Skip to content

Commit 3720596

Browse files
authored
Merge pull request #7282 from microting/copilot/fix-expression-changed-error
Fix ExpressionChangedAfterItHasBeenCheckedError in navigation menu drag-drop
2 parents f5ef038 + 138c765 commit 3720596

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

eform-client/src/app/modules/advanced/modules/navigation-menu/components/navigation-menu-page/navigation-menu-page.component.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,17 @@ export class NavigationMenuPageComponent implements OnInit, OnDestroy, AfterView
104104
this.dropLists.forEach(dropList => {
105105
this.dragDropService.register(dropList);
106106
});
107-
107+
108108
// Subscribe to changes in drop lists (for dynamically added dropdowns)
109109
this.dropLists.changes.subscribe(() => {
110-
// Clear and re-register all drop lists when the list changes
111-
this.dragDropService.dropLists = [];
112-
this.dropLists?.forEach(dropList => {
113-
this.dragDropService.register(dropList);
110+
// Use setTimeout to defer the update to avoid ExpressionChangedAfterItHasBeenCheckedError
111+
// This ensures the update happens after the current change detection cycle
112+
setTimeout(() => {
113+
// Clear and re-register all drop lists when the list changes
114+
this.dragDropService.dropLists = [];
115+
this.dropLists?.forEach(dropList => {
116+
this.dragDropService.register(dropList);
117+
});
114118
});
115119
});
116120
}

0 commit comments

Comments
 (0)