Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

[bug] utils.select buggy behavior

Open tomasmenezes opened this issue 3 years ago • 1 comments

  • When a sortable item selection is done programmatically using Sortable.utils.select() and Sortable.utils.deselect(), implicit deselection due to an outside click event does not occur if an item is not selected without these utilities beforehand.
  • Additionally, an utility-based selection also removes any prior hand-made selection.
  • These utilities also do not make use of the dispatchEvent function employed by onSelect and onDeselect.

These issues are reproducible in this Codepen.

Implicit deselection

  1. Click on 'Select first 2' or 'Select All' before any other event
  2. Click outside any of the sortable items
  • Observed behavior: Selection is unchanged
  • Expected behavior: Selection is fully deselected/removed

The proper behavior can be restored by vanilla selecting an item:

  1. Click on a sortable item to select it
  2. Click on 'Select first 2' or 'Select All' to create an util-based selection
  3. Click outside any of the sortable items
  • Observed behavior: Selection is fully deselected/removed, as expected

Util selection override

  1. Click on sortable 'D', for instance
  2. Click on 'Select first 2'
  • Observed behavior: Util-based selection overrides initial selection
  • Expected behavior: Util-based selection should complement initial selection such that selected items encompass 'A', 'B', 'D'

Versions sortablejs = ^1.15.0 @types/sortablejs = ^1.13.0

Note The Codepen example linked above uses the complete Sortable source from #2181 but the described behavior is unchanged from ^1.15.0.

tomasmenezes avatar Aug 19 '22 16:08 tomasmenezes

No solution to this yet?

ashauryn avatar Oct 14 '24 20:10 ashauryn