Skip to content

Commit 4c38d83

Browse files
committed
Remove textarea focus whilst recording to prevent key event interference
1 parent feb764f commit 4c38d83

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

llms/ui/modules/chat/index.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ export function useChatPrompt(ctx) {
479479
const VoiceInput = {
480480
template: `
481481
<button v-if="$state.config.extensions.includes('voice')" type="button"
482+
ref="voiceBtn"
482483
@click="toggleRecording"
483484
:class="['absolute bottom-12 right-2 size-8 flex items-center justify-center rounded-full hover:shadow transition-colors',
484485
isRecording
@@ -502,6 +503,7 @@ const VoiceInput = {
502503
`,
503504
setup() {
504505
const ctx = inject('ctx')
506+
const voiceBtn = ref(null)
505507
const isRecording = ref(false)
506508

507509
let mediaRecorder = null
@@ -561,6 +563,8 @@ const VoiceInput = {
561563
}
562564
mediaRecorder.start()
563565
isRecording.value = true
566+
// Focus the voice button to prevent textarea keyboard interference
567+
voiceBtn.value?.focus()
564568
} catch (err) {
565569
ctx.setError({ message: "Error accessing microphone: " + err.message })
566570
isProcessing.value = false
@@ -585,6 +589,9 @@ const VoiceInput = {
585589

586590
if (isProcessing.value) return
587591

592+
// Already triggered by key, ignore until key is released
593+
if (triggeredByKey.value) return
594+
588595
if (!isRecording.value) {
589596
// Start Recording (Press)
590597
triggeredByKey.value = true
@@ -628,6 +635,7 @@ const VoiceInput = {
628635
})
629636

630637
return {
638+
voiceBtn,
631639
isProcessing,
632640
isRecording,
633641
toggleRecording,

0 commit comments

Comments
 (0)