fix: improve spacebar shortcut to ignore buttons
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 <noreply@anthropic.com>
This commit is contained in:
@@ -99,8 +99,18 @@ export function AudioEditor() {
|
|||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
// Spacebar for play/pause - only if not typing in an input
|
// Spacebar for play/pause - only if not interacting with form elements
|
||||||
if (e.code === 'Space' && !(e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)) {
|
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();
|
e.preventDefault();
|
||||||
togglePlayPause();
|
togglePlayPause();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user