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

This commit is contained in:
gshawn3 2023-06-30 03:49:26 -07:00
parent 394ffa7b0a
commit 8a07c59baa

View File

@ -608,6 +608,11 @@ onUiLoaded(async() => {
// Handle keydown events // Handle keydown events
function handleKeyDown(event) { function handleKeyDown(event) {
// before activating shortcut, ensure user is not actively typing in an input field
if(event.target.nodeName === 'TEXTAREA' || event.target.nodeName === 'INPUT') {
event.preventDefault;
} else {
const hotkeyActions = { const hotkeyActions = {
[hotkeysConfig.canvas_hotkey_reset]: resetZoom, [hotkeysConfig.canvas_hotkey_reset]: resetZoom,
[hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap, [hotkeysConfig.canvas_hotkey_overlap]: toggleOverlap,
@ -627,6 +632,7 @@ onUiLoaded(async() => {
event.preventDefault(); event.preventDefault();
} }
} }
}
// Get Mouse position // Get Mouse position
function getMousePosition(e) { function getMousePosition(e) {
@ -687,6 +693,10 @@ 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) {
// before activating shortcut, ensure user is not actively typing in an input field
if(e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'INPUT') {
event.preventDefault;
} else {
if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) { if (!e.ctrlKey && !e.metaKey && isKeyDownHandlerAttached) {
e.preventDefault(); e.preventDefault();
document.activeElement.blur(); document.activeElement.blur();
@ -694,6 +704,7 @@ onUiLoaded(async() => {
} }
} }
} }
}
function handleMoveKeyUp(e) { function handleMoveKeyUp(e) {
if (e.code === hotkeysConfig.canvas_hotkey_move) { if (e.code === hotkeysConfig.canvas_hotkey_move) {