Repository navigation
fix: keep macro action order in sync after drag and drop - #3067
Merged
Merged
Conversation
Moving the list items changed the DOM order behind Angular's *ngFor view order, so the reordered model was rendered against a desynced view order, duplicating or misplacing macro actions (issue #3065). Restore the pre-drag DOM order in DragAndDropDirective before emitting the reordered model so Angular re-renders it consistently, and drop the obsolete isMacroReordering content-based trackBy hack that made Angular move views against the stale DOM order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3065.
Problem
Reordering macro actions moved the actual list DOM nodes, which put the DOM out of sync with the view order Angular tracks for
*ngFor. The reordered model was then rendered against that desynced view order, so actions were duplicated or left in place instead of moving.Fix
DragAndDropDirectivenow records the container's child order onpointerdownand restores it inonPointerUp(after computing the reordered model, before emitting). The live drag preview is unchanged; the DOM is handed back to Angular in the order its view container expects, so Angular renders the emitted model consistently.MacroListComponentdrops the obsoleteisMacroReorderingcontent-basedtrackByworkaround and uses a plain indextrackBy. That workaround was only needed for the previous dragula-based flow (which left the DOM moved); with the restore it made Angular move views against the stale DOM order and reintroduced the bug. Normal editing still uses index keys, so the in-line command editor keeps its focus.Verification
Built
uhk-weband drove the real app in Chromium with synthetic pointer events:data-indexorder stays0,1,2and visible order equals model order).trackBychange the same harness reproduced the desync (1,2,0/2,0,1).ng lintpasses with 0 errors (one pre-existing unrelated warning) andnpm testpasses 33/33.