From 2b6d313c80356d2ef937c4255ad46a703d5bae85 Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Fri, 10 May 2024 11:35:04 +0000 Subject: [PATCH] disable duplication shortcut key while drawing --- .../imports/ui/components/whiteboard/component.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx index c92665b6e4..1575c0fd78 100644 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx @@ -94,6 +94,7 @@ export default function Whiteboard(props) { const [zoom, setZoom] = React.useState(HUNDRED_PERCENT); const [tldrawZoom, setTldrawZoom] = React.useState(1); const zoomValueRef = React.useRef(zoomValue); + const isMouseDownRef = React.useRef(false); const [isMounting, setIsMounting] = React.useState(true); const prevShapes = usePrevious(shapes); const prevSlidePosition = usePrevious(slidePosition); @@ -221,6 +222,7 @@ export default function Whiteboard(props) { tldrawAPI?.completeSession?.(); } } + isMouseDownRef.current = false; }; const checkVisibility = () => { @@ -259,12 +261,18 @@ export default function Whiteboard(props) { window.dispatchEvent(new Event('resize')); } + const setIsMouseDown = () => { + isMouseDownRef.current = true; + } + React.useEffect(() => { document.addEventListener('mouseup', checkClientBounds); document.addEventListener('visibilitychange', checkVisibility); + document.addEventListener('mousedown', setIsMouseDown); return () => { document.removeEventListener('mouseup', checkClientBounds); + document.removeEventListener('mousedown', setIsMouseDown); document.removeEventListener('visibilitychange', checkVisibility); const canvas = document.getElementById('canvas'); if (canvas) { @@ -617,6 +625,12 @@ export default function Whiteboard(props) { const handleOnKeyDown = (event) => { const { which, ctrlKey } = event; + if (isMouseDownRef.current) { + event.preventDefault(); + event.stopPropagation(); + return; + } + switch (which) { case KEY_CODES.ARROW_LEFT: case KEY_CODES.PAGE_UP: