fix(header): allow sorting on mobile devices with reorderable enabled#710
Conversation
13d38a1 to
b3c11bd
Compare
There was a problem hiding this comment.
Code Review
This pull request updates the DatatableDraggableDirective to manage dragging state via a new setDragging helper, removes event.preventDefault() on touch start to allow click events to proceed, and adds a corresponding unit test. The review feedback suggests improving the touch-start race condition check by verifying the specific touch identifier instead of just checking if it is defined, and wrapping the unit test's fake timer logic in a try...finally block to prevent test flakiness in case of assertion failures.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
aab2ccc to
0fbf007
Compare
There was a problem hiding this comment.
Pull request overview
Fixes mobile header sorting when column reordering is enabled by avoiding suppression of the synthetic click generated from touch interactions, while still supporting long-press drag behavior for reordering.
Changes:
- Removed
preventDefault()fromtouchstartand moved touch cancellation totouchmoveonce dragging begins. - Added
setDragging()to managecolumn.draggingduring drag lifecycle so sort can be skipped only when an actual drag starts. - Added a unit test for short touch interactions before the drag delay.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| projects/ngx-datatable/src/lib/directives/draggable.directive.spec.ts | Adds/adjusts unit tests around delayed touch interactions to ensure short touches don’t start a drag. |
| projects/ngx-datatable/src/lib/directives/datatable-draggable.directive.ts | Updates touch handling to allow click-based sorting on mobile while preserving delayed drag start and drag state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0fbf007 to
1798a1f
Compare
The touchstart handler was calling preventDefault() immediately, which prevented synthetic click events from firing. This blocked sorting when tapping headers on mobile devices with reorderable enabled. Removed preventDefault() from touchstart and added proper dragging state management to the draggable directive. Closes #692
1798a1f to
ce774a2
Compare
Description
On mobile devices, sorting was not working when tapping on a header due to a conflict with the
[reorderable]input. Thetouchstarthandler in the draggable directive was callingevent.preventDefault()immediately, which prevented the synthetic click event from firing.Changes
preventDefault()fromtouchstarthandler inDatatableDraggableDirectivesetDragging()method to properly managecolumn.draggingstateif (this.touchId !== undefined)to ensure drag only starts if touch is still active after delayHow It Works
column.draggingis set totrue, sort handler skipsTesting
All 191 unit tests pass.
Closes #692