Skip to content

Commit

Permalink
Disable hotkey when focusing on a any input field
Browse files Browse the repository at this point in the history
- Disable hotkey when focusing on a any input field, textarea, or
CodeMirror element
- No longer automatically play a song when opening lyrics editor
  • Loading branch information
tranxuanthang committed May 24, 2024
1 parent 12affd4 commit ae6cf5c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "lrcget"
version = "0.3.1"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
version = "0.3.2"
description = "Utility for mass-downloading LRC synced lyrics for your offline music library."
authors = ["tranxuanthang"]
license = "MIT"
repository = "https://github.com/tranxuanthang/lrcget"
edition = "2021"
rust-version = "1.57"

Expand Down
9 changes: 8 additions & 1 deletion src/components/NowPlaying.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ onUnmounted(async () => {
onMounted(async () => {
keydownEvent.value = document.addEventListener('keydown', (event) => {
console.log(`is hotkey: ${isHotkey.value}`)
if (!isHotkey.value) {
// hotkey is explicitly disabled
return
}
const target = event.target
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.closest('.v-codemirror')) {
// Do nothing if the target is an input, textarea, or CodeMirror element
return
}
Expand Down
8 changes: 5 additions & 3 deletions src/components/library/EditLyrics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const AsyncCodemirror = defineAsyncComponent(async () => {
})
const { disableHotkey, enableHotkey } = useGlobalState()
const { status, duration, progress, playTrack, pause, resume, seek } = usePlayer()
const { status, duration, progress, playingTrack, playTrack, pause, resume, seek } = usePlayer()
const toast = useToast()
const props = defineProps(['isShow'])
const { editingTrack } = useEditLyrics()
Expand Down Expand Up @@ -391,8 +391,10 @@ onMounted(async () => {
unifiedLyrics.value = ''
}
stop()
playTrack(editingTrack.value)
if (playingTrack.value && playingTrack.value.id !== editingTrack.value.id) {
playTrack(editingTrack.value)
pause()
}
const parsed = Lrc.parse(unifiedLyrics.value)
Expand Down

0 comments on commit ae6cf5c

Please sign in to comment.