Skip to content

Commit

Permalink
fix: only allow row drag on cell w/dnd or cell-reorder (#939)
Browse files Browse the repository at this point in the history
* fix: only allow row drag on cell w/`dnd` or `cell-reorder`
- a previous PR #897 caused a regression on a cell with a select dropdown (like `Slick.Editors.YesNoSelect`), the regression was caused by the implementation of Draggable `allowDragFromClosest` which will check if current DOM element is `.slick-cell` or if not it will also try its ancestor and that caused the regression because the cell with the editor also had a `.slick-cell` and so the code taught that the user started a drag and it cancelled event bubbling which in turn also prevented the select dropdown to be clickable.
- to fix this issue we need to make sure that the cell is queried not just with `div.slick-cell` but also with certain CSS classes, we need to check if parent has either `.dnd` or `.cell-reorder` to permit the dragging when checking parent cell with `allowDragFromClosest`
  • Loading branch information
ghiscoding authored Dec 1, 2023
1 parent 3795c5f commit 0f07161
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ if (typeof Slick === "undefined") {
slickDraggableInstance = Slick.Draggable({
containerElement: _container,
allowDragFrom: 'div.slick-cell',
allowDragFromClosest: 'div.slick-cell',
// the slick cell parent must always contain `.dnd` and/or `.cell-reorder` class to be identified as draggable
allowDragFromClosest: 'div.slick-cell.dnd, div.slick-cell.cell-reorder',
onDragInit: handleDragInit,
onDragStart: handleDragStart,
onDrag: handleDrag,
Expand Down

0 comments on commit 0f07161

Please sign in to comment.