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

fix: disabling start for middle mouse button #852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

1 participant