-
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
correctly blocking onClick for all element types #353
Conversation
src/view/style-marshal/get-styles.js
Outdated
@@ -113,8 +114,8 @@ export default (styleContext: string): Styles => { | |||
// > Applied while the user is actively dragging | |||
|
|||
// cursor: grab | |||
// We apply this by default for an improved user experience. It is such a common default that we | |||
// bake it right in. Consumers can opt out of this by adding a selector with higher specificity | |||
// We apply apply this style to the body in case the user pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolute nitpick but you've written 'apply' here twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
It sucks we need to do this - but it is for the best |
I was not happy to loose wheel scrolling so I have changed how we do post drag click prevention. It is working really well. |
A point for discussion is whether this should be a breaking change. I have currently removed Thoughts @jaredcrowe @Blasz ? My personal thought is to keep the api as tight as possible and drop |
README.md
Outdated
@@ -366,6 +366,12 @@ point-events: none; | |||
|
|||
**Styles applied using the `data-react-beautiful-dnd-draggable` attribute** | |||
|
|||
We apply a cursor while dragging to give user feedback that a drag is occurring. You are welcome to override this by applying your own cursor to the element with a greater specificity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to remove these new comments (they are no longer needed)
@@ -1142,23 +1146,20 @@ Controlling a whole draggable by just a part of it | |||
You can override some of the `dragHandleProps` props with your own behavior if you need to. | |||
|
|||
```js | |||
const myOnClick = event => console.log('clicked on', event.target); | |||
const myOnMouseDown = event => console.log('mouse down on', event.target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer using 'click' as part of the example
src/view/style-marshal/get-styles.js
Outdated
@@ -65,9 +64,11 @@ export default (styleContext: string): Styles => { | |||
cursor: grab; | |||
} | |||
`, | |||
blockPointerEvents: ` | |||
whileActiveDragging: ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be undone
I have tested this on our supported desktop browsers. I still need to test it on mobile (ios and andriod) |
It is looking good on ios. I'll check andriod after lunch |
If it wasn't for the fact that anchors won't always get their onClick called now I would have said make DragHandleProps.onClick a no-op and remove it next major. But since that behaviour is changing I agree that we should probably make a breaking change. |
Fixes #273.
This is required for #10.
onClick
event handlers are not firing on thedrag handle
because it haspointer-events: none;
applied to it. This means that it fires on the parent. Confusingly theonClick
handler will fire on the element if the element is ananchor
. There is a work around (see #10) but it is hacky. This change would makeonClick
fire correctly on thedrag handle
every time. It involves removingpointer-events: none
off the draggingdrag handle
. This has no performance implications.There is a drawback. By changing this you will no longer be able to use the mouse wheel to scroll a
Droppable
underneath a dragging item. Disabling pointer events allowed the user to 'scroll through' the dragging item. Turning them back on means that they can no longer do this. However, I think given that users can now automatically scroll the window and scroll containers by using mouse movement this is acceptable. I have investigated the other drag and drop libraries out there that I could and they all have this restriction.I think on the whole this is a positive and useful change as it delivers more thoroughly on our attempt to correctly block click events