fix: Space bar triggers playback even on button roles

This commit is contained in:
Phan An 2024-04-24 21:29:13 +02:00
parent 617fc9d0eb
commit ecbc7de7fa

View file

@ -11,7 +11,15 @@ import { favoriteStore, queueStore } from '@/stores'
const onKeyStroke = (key: KeyFilter, callback: (e: KeyboardEvent) => void) => { const onKeyStroke = (key: KeyFilter, callback: (e: KeyboardEvent) => void) => {
baseOnKeyStroke(key, e => { baseOnKeyStroke(key, e => {
if (e.altKey || e.ctrlKey || e.metaKey) return if (e.altKey || e.ctrlKey || e.metaKey) return
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return
if (e.target instanceof HTMLInputElement
|| e.target instanceof HTMLTextAreaElement
|| e.target instanceof HTMLButtonElement
) return
const role = (e.target as HTMLElement).getAttribute('role')
if (role === 'button' || role === 'checkbox') return
e.preventDefault() e.preventDefault()
callback(e) callback(e)
}) })