Skip to content

[bug] draggable params doesn't behave the same if it's not present vs undefined / null / empty / false #2378

Closed
@jamesst20

Description

@jamesst20

Versions

SortableJS 1.15.2

Reproduction

CodeSandbox

Why this is trouble

I need to write a wrapper in my app that takes optional params like

type SortableItem = { position: number };
type UseSortableProps = { draggable?: string; handle?: string };

export const useSortable = ({ draggable, handle }: UseSortableProps) => {
  ...
  new Sortable(node, {
      animation: 150,
      dragClass: "bg-slate-200",
      ghostClass: "bg-slate-200",
      handle,
      draggable,
      onEnd: (e) => (items = updatePosition(items, e.oldIndex!, e.newIndex!, offset)),
    });
}

I have an ugly workaround for now but I don't think this should behave like this.

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