Skip to content

[bug] utils.select buggy behavior  #2189

Open
@tomasmenezes

Description

@tomasmenezes
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions