Skip to content

Conversation

cgood92
Copy link

@cgood92 cgood92 commented Aug 22, 2022

Fix: disabling start for middle mouse button

There are 5 possible values for event.button:

0: Main button pressed, usually the left button or the un-initialized state
1: Auxiliary button pressed, usually the wheel button or the middle button (if present)
2: Secondary button pressed, usually the right button
3: Fourth button, typically the Browser Back button
4: Fifth button, typically the Browser Forward button

(Source: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)

We should not start dragging if either middle or right mouse buttons are clicked

I did not see any unit tests, please let me know if I missed that, as I would be happy to add a unit test.

There are 3 possible values for `event.button`:
- 0: left mouse button
- 1: middle mouse button
- 2: right mouse button

We should not start dragging if either middle or right mouse buttons are clicked
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5b31ad4:

Sandbox Source
react-sortable-hoc-starter Configuration

@@ -124,7 +126,7 @@ export default function sortableContainer(
handleStart = (event) => {
const {distance, shouldCancelStart} = this.props;

if (event.button === 2 || shouldCancelStart(event)) {
if (event.button !== LEFT_MOUSE_BUTTON || shouldCancelStart(event)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note: event.button is well supported: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button, and could be a number 0-4. But, we should only activate for left mouse button.

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

Successfully merging this pull request may close these issues.

1 participant