Repository navigation
fix(query-builder): end drag subscriptions on chip drop and destroy - #18041
Merged
Merged
Conversation
Close the drag ghost mousemove and keyboard subscriptions whenever a drag ends, including drops handled by a target condition, and when the query builder is destroyed. Return false from the drop ghost row check when the drag ghost is gone.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Query Builder drag-cleanup changes.
No open issues 🎉
What changed in this PR
Fixes Query Builder drag cleanup for #17804, restoring application stability after condition drops and preventing errors when the component is destroyed mid-drag.
Changes:
- Centralizes drag subscription cleanup and clears the pending ghost timeout on destruction.
- Guards against a missing drag ghost and adds five regression tests covering cleanup, stability, and subsequent drags.
- Documents the user-visible fixes in the changelog.
| File | Description |
|---|---|
| projects/igniteui-angular/query-builder/src/query-builder/query-builder.component.spec.ts | Adds drag lifecycle regression tests and updates the timer-related comment. |
| projects/igniteui-angular/query-builder/src/query-builder/query-builder-drag.service.ts | Centralizes subscription cleanup, adds destruction handling, and guards missing ghosts. |
| CHANGELOG.md | Records the stability and mid-drag destruction fixes. |
Review effort: Balanced
ivanvpetrov
marked this pull request as ready for review
November 24, 2026 14:15
viktorkombov
reviewed
Dec 1, 2026
Contributor
There was a problem hiding this comment.
@ivanvpetrov, CHANGELOG.md conflicts with master, and the entry is under 22.3.1, which is already released (22.3.2 too). Please move it to a new ## 22.3.3. Also 22.3.x and 21.2.x have the same bug (only onMoveEnd() unsubscribes, there is no ngOnDestroy), so this needs backports there.
This was referenced Dec 3, 2026
viktorkombov
reviewed
Dec 3, 2026
viktorkombov
previously approved these changes
Dec 4, 2026
kdinev
enabled auto-merge (squash)
December 4, 2026 12:10
kdinev
approved these changes
Dec 4, 2026
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.
Closes #17804
Description
A condition dropped with the mouse on another condition no longer leaves the drag service listening, so the application becomes stable again. Destroying the query builder while a condition is dragged no longer throws.
resetDragAndDrop(true)now closes the drag ghostmousemovesubscription and the keyboard subscription. It runs at the end of every drag, however it ends: move end, a drop on a condition, a keyboard drop, or a cancel. The four separateunsubscribe()calls it replaces were removed.IgxQueryBuilderDragServiceimplementsngOnDestroy. It closes both subscriptions and clears the pending ghost z-index timeout. The service is in the tree component'sproviders, so Angular calls it when the tree is destroyed, as withIgxTreeNavigationService.dragGhostIsOnDropGhostRow()returnsfalsewhen the drag ghost is gone, instead of throwing.Motivation / Context
On release,
igxDragdispatches the drop to the drop area under the pointer before the dragged chip emitsmoveEnd. When that area is another condition's chip (dragDrop) or its wrapper (dropped→onDivDropped),onChipDropped()runs first and clears the drag state.onMoveEnd()then returns early and never reaches theunsubscribe()calls, which were the only ones for the ghostmousemovesubscription. Effects:sampleTime(100)timer keeps running in the Angular zone, soApplicationRef.isStable/fixture.whenStable()never settle.closedguard sees the old subscription, which is attached to the removed ghost of the previous drag.igxDragremoves the ghost without ending the drag. A pending sampled mouse move then callsonChipLeave()→dragGhostIsOnDropGhostRow(), which throwsCannot read properties of null (reading 'getBoundingClientRect').Note on the issue's repro: the TypeError needs a destroy during a drag whose ghost the subscription is attached to. After a drop on a condition (step 2), the next drag has no ghost subscription, so step 4 as written doesn't reproduce it.
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
Query Builder (condition drag and drop), including the grids' advanced filtering dialog
How Has This Been Tested?
New specs in the
Drag and dropsection ofquery-builder.component.spec.ts:moveEnd) closes both subscriptions.fixture.isStable()becomestrue(real timers).onChipLeave().onChipLeave()doesn't throw when the drag ghost is gone, and removes the drop ghost.All five fail without the fix and pass with it. The comment in the spec that described the leak as expected was updated.
Runs:
query-builderspecs: 148 passedgrid-filtering-advancedspecs: 55 passednpm run lint:lib: no new errors or warningsTest Configuration:
Screenshots / Recordings
N/A: no visual change.
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)