Skip to content

Commit a9ba47a

Browse files
committed
fix: prevent recorder from emitting click event when pressing space
1 parent 220a7f3 commit a9ba47a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/LibRecorder/LibRecorder.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
v-bind="{...ariaLabel, ...$attrs, class:undefined}"
3636
@blur="handleBlurRecorder($event)"
3737
@click="handleClickRecorder($event)"
38-
@keydown.space.prevent="handleClickRecorder($event)"
38+
@keydown.space.prevent="handleClickRecorder($event, true)"
3939
>
4040
<!-- :aria-description="recording ? recordingTitle : ''" -->
4141
<div
@@ -210,11 +210,14 @@ const handleBlurRecorder = (e: FocusEvent): void => {
210210
}
211211
}
212212
213-
const handleClickRecorder = (e: MouseEvent | KeyboardEvent): void => {
213+
const handleClickRecorder = (e: MouseEvent | KeyboardEvent, isSpaceKey: boolean = false): void => {
214214
if (!canEdit.value) return
215-
recorderEl.value?.focus()
215+
if (!recording.value) {
216+
recorderEl.value?.focus()
217+
}
216218
// toggle if clicking on the recording indicator, otherwise only allow starting recording, so if needed, clicks can be recorded
217219
if (props.recorder || props.binders) {
220+
if (isSpaceKey) { return }
218221
emits("recorder:click", { event: e, indicator: recorderIndicatorEl.value!, input: recorderEl.value! })
219222
}
220223
}

0 commit comments

Comments
 (0)