React-sortable-hoc: <a> onClick isn't trigged

Created on 30 Oct 2017  路  10Comments  路  Source: clauderic/react-sortable-hoc

No <a> children of SortableElement ever triggers onClick due this:
https://github.com/clauderic/react-sortable-hoc/commit/008d8789acc23230a0ef18ccd270819a79a5250d

Reproduceable example:
https://codesandbox.io/s/xoynwoo40o

Most helpful comment

In my case I have added the argument pressDelay={100} to the Sortable List props. So I have :

<SortableList pressDelay={100} items={this.state.items} onSortEnd={this.onSortEnd} />

In that way you can trigger the click on the a AND drag the a less than 1 s after the click.

All 10 comments

You can define a value for the distance prop on the SortableContainer.

https://github.com/clauderic/react-sortable-hoc#click-events-being-swallowed

@cusxio, thanks for the help, but it doesn't solve the problem. Once mouseDown was prevented, click will never be fired. You can see it right here: https://codesandbox.io/s/91l82zxyjr

Were you able to solve this? I'm facing the same issue.

Any suggestion for workaround?

It depends too much on your application and specific details. In my case, I've used the SortableHandler to make only a image below the link draggable

In my case I have added the argument pressDelay={100} to the Sortable List props. So I have :

<SortableList pressDelay={100} items={this.state.items} onSortEnd={this.onSortEnd} />

In that way you can trigger the click on the a AND drag the a less than 1 s after the click.

I changed <a> to <button> and onClick starts working

Add distance={ 2 } to your

https://codesandbox.io/s/n9160x16n4

Refer to how this component updates the value of state, because I have a delete event, click to delete one

Was this page helpful?
0 / 5 - 0 ratings