Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamesst20 opened this issue May 28, 2024 · 0 comments

Comments

@jamesst20
Copy link

jamesst20 commented May 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant