From 5b31ad44c696592cd0b0a05516e54051596fb116 Mon Sep 17 00:00:00 2001 From: Clint Goodman Date: Mon, 22 Aug 2022 13:15:36 -0600 Subject: [PATCH] fix: disabling start for middle mouse button 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 --- src/SortableContainer/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SortableContainer/index.js b/src/SortableContainer/index.js index 9b24a045..02ec5d68 100644 --- a/src/SortableContainer/index.js +++ b/src/SortableContainer/index.js @@ -36,6 +36,8 @@ import { defaultKeyCodes, } from './props'; +const LEFT_MOUSE_BUTTON = 0; + export const SortableContext = React.createContext({ manager: {}, }); @@ -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; }