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(whiteboard): Disable Duplication Shortcut Key While Drawing #20216

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -221,6 +222,7 @@ export default function Whiteboard(props) {
tldrawAPI?.completeSession?.();
}
}
isMouseDownRef.current = false;
};

const checkVisibility = () => {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down