Skip to content

Commit

Permalink
Fix input fields refocusing during undo/redo on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kettek committed Oct 25, 2024
1 parent 1db5bc6 commit f90ed34
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/Shortcuts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
}
window.addEventListener('keydown', (event: KeyboardEvent) => {
if (document.activeElement?.tagName === 'INPUT' || document.activeElement?.tagName === 'TEXTAREA') return
// On windows, previously focused input fields are refocused if ctrl-z or ctrl-y is used, so we have to catch those conditions to prevent the input field from receiving the undo/redo operation.
if (event.target === document.body && (event.ctrlKey || (event.ctrlKey && event.shiftKey)) && (event.key === 'z' || event.key === 'y')) {
event.preventDefault()
}
if (disabled) return
if (event.key === 'Alt') event.preventDefault() // Prevent alt because that opens a menu that doesn't exist.
let key = normalizeKey(event.key, event.code)
Expand Down

0 comments on commit f90ed34

Please sign in to comment.