mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-20 07:41:22 +02:00
Fix tauri event listener hook
This commit is contained in:
@@ -20,9 +20,20 @@ if (osType !== 'macos') {
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
// Hack to not go back in history on backspace. Check for document body
|
||||
// or else it will prevent backspace in input fields.
|
||||
if (e.key === 'Backspace' && e.target === document.body) e.preventDefault();
|
||||
const rx = /input|select|textarea/i;
|
||||
|
||||
const target = e.target;
|
||||
if (e.key !== 'Backspace') return;
|
||||
if (!(target instanceof Element)) return;
|
||||
if (target.getAttribute('contenteditable') !== null) return;
|
||||
|
||||
if (
|
||||
!rx.test(target.tagName) ||
|
||||
('disabled' in target && target.disabled) ||
|
||||
('readOnly' in target && target.readOnly)
|
||||
) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Creating React root');
|
||||
|
||||
Reference in New Issue
Block a user