-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Containing element receives mouse click after dragging #273
Comments
For some reason, after dragging an item the parent draggable receives a mouse click. The workaround is to use onMouseDown for deselecting tags
This is very strange. I can see the issue in the basic example, but i cannot reproduce it in our examples. It looks like the draggable wrapper div is the target of the event which seems strange. I'll keep looking |
Webpack bin seems to be down so i'll take a look at this later |
Okay, I can see what the issue is: When we are dragging we add This is not the case for anchor tags which still get the click event 🙃 Some suggestions:
Sadly I do not think we can remove |
Given that there is no further action to be taken at this time i'll close this. If people think that this problem should be solve more thoroughly we could revisit it. It will be a slightly different conversation after #27 lands. |
This makes me sad. I am going to see if we can do better |
The trouble is even when if we remove For now here is the best workaround: +<div onClick={provided.dragHandleProps.onClick}>
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={getItemStyle(
snapshot.isDragging,
provided.draggableProps.style
)}
>
{item.content}
</div>
{provided.placeholder}
</div> By binding the drag handle onClick function to the parent you get the correct click blocking behaviour. This will allow actual clicks to go through, while blocking clicks after a drag (which is what already occurs on an anchor) |
@alexreardon thanks for looking into this - your response was very speedy! 😄 The workaround seems fine to me. |
The best fix would require us to add an event handler to the parent. This could done without the consumers needing to bind it... |
Fix two bugs in Riot due to a single bug in react-b-dnd Fixes element-hq/element-web#6253 Fixes element-hq/element-web#6156
Fix two bugs in Riot due to a single bug in react-b-dnd Fixes element-hq/element-web#6253 Fixes element-hq/element-web#6156
…rdness Workaround for atlassian/react-beautiful-dnd#273
Hey @alexreardon, is this working? I'm with a similar error on IE 11, and I tried with what you proposed but no success.
|
Hi @alexreardon , I see that future versions of the project removed the |
Have you tried |
A little helper while awaiting anything 'official' the onClick event of the parent has property defaultPrevented set to true after a drag event on its child. So in your parent onClick event handler you can do something like: if (!e.defaultPrevented) doSomething... |
Bug or feature request?
Bug
Expected behavior
A mouse click event is not emitted on the parent element of the draggables after dragging and dropping.
Actual behavior
A mouse click event is emitted on the parent element of the draggables after dragging and dropping.
Browser version
Chrome Version 63.0.3239.84 (Official Build) (64-bit)
Demo
See logs of the following demo after dragging and dropping:
https://www.webpackbin.com/bins/-L2yYhx5eZi1MJnlU-79
The text was updated successfully, but these errors were encountered: