From c6b9cb9af6fecd09b5a066c8d888aa9e684b1330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 18 Nov 2025 07:14:10 +0100 Subject: [PATCH] fix: improve spacebar shortcut to ignore buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated spacebar handler to skip when focus is on: - Input fields - Textareas - Buttons (HTMLButtonElement) - Elements with role="button" This prevents spacebar from triggering play/pause when clicking playback control buttons or other UI controls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- components/editor/AudioEditor.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/editor/AudioEditor.tsx b/components/editor/AudioEditor.tsx index cc8379e..a1fea09 100644 --- a/components/editor/AudioEditor.tsx +++ b/components/editor/AudioEditor.tsx @@ -99,8 +99,18 @@ export function AudioEditor() { // Keyboard shortcuts React.useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { - // Spacebar for play/pause - only if not typing in an input - if (e.code === 'Space' && !(e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)) { + // Spacebar for play/pause - only if not interacting with form elements + if (e.code === 'Space') { + const target = e.target as HTMLElement; + // Don't trigger if user is typing or interacting with buttons/form elements + if ( + target instanceof HTMLInputElement || + target instanceof HTMLTextAreaElement || + target instanceof HTMLButtonElement || + target.getAttribute('role') === 'button' + ) { + return; + } e.preventDefault(); togglePlayPause(); }