Skip to content

Commit

Permalink
fix: disabling start for middle mouse button
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cgood92 committed Aug 22, 2022
1 parent caf3c4f commit 5b31ad4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SortableContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import {
defaultKeyCodes,
} from './props';

const LEFT_MOUSE_BUTTON = 0;

export const SortableContext = React.createContext({
manager: {},
});
Expand Down Expand Up @@ -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)) {
return;
}

Expand Down

0 comments on commit 5b31ad4

Please sign in to comment.