Skip to content

fix(query-builder): end drag subscriptions on chip drop and destroy - 22.3.x - #18089

Merged
kdinev merged 2 commits into
22.3.xfrom
ipetrov/fix-17804-22.3.x
Dec 4, 2026
Merged

kdinev merged 2 commits into
22.3.xfrom
ipetrov/fix-17804-22.3.x

Conversation

@ivanvpetrov

@ivanvpetrov ivanvpetrov commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #17804

Backport of #18041 to 22.3.x.

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 ghost mousemove subscription 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 separate unsubscribe() calls it replaces were removed.
  • IgxQueryBuilderDragService implements ngOnDestroy. It closes both subscriptions and clears the pending ghost z-index timeout.
  • dragGhostIsOnDropGhostRow() returns false when the drag ghost is gone, instead of throwing.

The code is cherry-picked unchanged from #18041. In CHANGELOG.md, the entry is in a new 22.3.3 section.

Motivation / Context

On release, igxDrag dispatches the drop to the drop area under the pointer before the dragged chip emits moveEnd. 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 the unsubscribe() calls, which were the only ones for the ghost mousemove subscription. Effects:

  • The sampleTime(100) timer keeps running in the Angular zone, so ApplicationRef.isStable / fixture.whenStable() never settle.
  • The next drag doesn't subscribe to its ghost, because the closed guard sees the old subscription, which is attached to the removed ghost of the previous drag.
  • If the query builder is destroyed mid-drag, igxDrag removes the ghost without ending the drag. A pending sampled mouse move then calls onChipLeave() → dragGhostIsOnDropGhostRow(), which throws Cannot read properties of null (reading 'getBoundingClientRect').

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

Query Builder (condition drag and drop), including the grids' advanced filtering dialog

How Has This Been Tested?

The five specs from #18041 (Drag and drop section of query-builder.component.spec.ts) fail on 22.3.x without the fix and pass with it.

  • Unit tests
  • Manual testing
  • Automated e2e tests

Runs on this branch:

  • query-builder specs: 148 passed
  • grid-filtering-advanced specs: 54 passed
  • ESLint on the changed files: no new errors or warnings

Test Configuration:

  • Angular version: 22.2.3
  • Browser(s): Chromium (Vitest browser mode via Playwright)
  • OS: Windows 11

Screenshots / Recordings

N/A: no visual change.

Checklist:

  • All relevant labels have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

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.

Backport of #18041 to 22.3.x.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the query-builder drag-cleanup backport.

No open issues 🎉

What changed in this PR

Backports #18041 to 22.3.x, fixing query-builder drag cleanup to restore application stability and prevent errors when destroyed mid-drag.

Changes:

  • Centralizes drag subscription cleanup and adds destruction cleanup.
  • Guards against missing drag ghosts and adds five regression tests.
  • Documents the fix under version 22.3.3.
File Description
projects/​igniteui-angular/​query-builder/​src/​query-builder/​query-builder.component.spec.ts Adds regression coverage for cleanup, stability, subsequent drags, and missing ghosts.
projects/​igniteui-angular/​query-builder/​src/​query-builder/​query-builder-drag.service.ts Cleans up subscriptions and the timeout; safely handles missing ghosts.
CHANGELOG.md Records the query-builder fix for 22.3.3.

Review effort: Balanced

@ivanvpetrov
ivanvpetrov marked this pull request as ready for review December 3, 2026 10:27
@viktorkombov viktorkombov added ✅ status: verified Applies to PRs that have passed manual verification and removed ❌ status: awaiting-test PRs awaiting manual verification labels Dec 4, 2026
@kdinev
kdinev merged commit 15f4137 into 22.3.x Dec 4, 2026
6 checks passed
@kdinev
kdinev deleted the ipetrov/fix-17804-22.3.x branch December 4, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drag-drop query-builder version: 22.3.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query Builder: drag ghost mousemove subscription outlives the drag and throws TypeError

4 participants