Commit 8a07c59b authored by gshawn3's avatar gshawn3

fix for #11534: canvas zoom and pan extension hijacking shortcut keys

parent 394ffa7b
...@@ -608,23 +608,29 @@ onUiLoaded(async() => { ...@@ -608,23 +608,29 @@ onUiLoaded(async() => {
// Handle keydown events // Handle keydown events
function handleKeyDown(event) { function handleKeyDown(event) {
const hotkeyActions = { // before activating shortcut, ensure user is not actively typing in an input field
[hotkeysConfig.canvas_hotkey_reset]: resetZoom, if(event.target.nodeName === 'TEXTAREA' || event.target.nodeName === 'INPUT') {
[hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap, event.preventDefault;
[hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen } else {
};
const action = hotkeyActions[event.code]; const hotkeyActions = {
if (action) { [hotkeysConfig.canvas_hotkey_reset]: resetZoom,
event.preventDefault(); [hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap,
action(event); [hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen
} };
if ( const action = hotkeyActions[event.code];
isModifierKey(event, hotkeysConfig.canvas_hotkey_zoom) || if (action) {
isModifierKey(event, hotkeysConfig.canvas_hotkey_adjust) event.preventDefault();
) { action(event);
event.preventDefault(); }
if (
isModifierKey(event, hotkeysConfig.canvas_hotkey_zoom) ||
isModifierKey(event, hotkeysConfig.canvas_hotkey_adjust)
) {
event.preventDefault();
}
} }
} }
...@@ -687,10 +693,15 @@ onUiLoaded(async() => { ...@@ -687,10 +693,15 @@ onUiLoaded(async() => {
// Handle the move event for pan functionality. Updates the panX and panY variables and applies the new transform to the target element. // Handle the move event for pan functionality. Updates the panX and panY variables and applies the new transform to the target element.
function handleMoveKeyDown(e) { function handleMoveKeyDown(e) {
if (e.code === hotkeysConfig.canvas_hotkey_move) { if (e.code === hotkeysConfig.canvas_hotkey_move) {
if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) { // before activating shortcut, ensure user is not actively typing in an input field
e.preventDefault(); if(e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'INPUT') {
document.activeElement.blur(); event.preventDefault;
isMoving = true; } else {
if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) {
e.preventDefault();
document.activeElement.blur();
isMoving = true;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment