From a8e7fd52a970590868f1f1cb6fe97e75a0a4094b Mon Sep 17 00:00:00 2001 From: Tuur Martens Date: Fri, 3 Feb 2023 15:21:29 +0100 Subject: [PATCH] fix(Tiptap): don't consume key events if no items (#1594) --- components/tiptap/TiptapEmojiList.vue | 3 +++ components/tiptap/TiptapHashtagList.vue | 3 +++ components/tiptap/TiptapMentionList.vue | 3 +++ 3 files changed, 9 insertions(+) diff --git a/components/tiptap/TiptapEmojiList.vue b/components/tiptap/TiptapEmojiList.vue index cd58eee4..0efcda9c 100644 --- a/components/tiptap/TiptapEmojiList.vue +++ b/components/tiptap/TiptapEmojiList.vue @@ -40,6 +40,9 @@ watch(items, () => { }) function onKeyDown(event: KeyboardEvent) { + if (items.length === 0) + return false + if (event.key === 'ArrowUp') { selectedIndex = ((selectedIndex + items.length) - 1) % items.length return true diff --git a/components/tiptap/TiptapHashtagList.vue b/components/tiptap/TiptapHashtagList.vue index 0aa486aa..84bb344b 100644 --- a/components/tiptap/TiptapHashtagList.vue +++ b/components/tiptap/TiptapHashtagList.vue @@ -15,6 +15,9 @@ watch(items, () => { }) function onKeyDown(event: KeyboardEvent) { + if (items.length === 0) + return false + if (event.key === 'ArrowUp') { selectedIndex = ((selectedIndex + items.length) - 1) % items.length return true diff --git a/components/tiptap/TiptapMentionList.vue b/components/tiptap/TiptapMentionList.vue index 81f0e5c6..f2ab0d2d 100644 --- a/components/tiptap/TiptapMentionList.vue +++ b/components/tiptap/TiptapMentionList.vue @@ -15,6 +15,9 @@ watch(items, () => { }) function onKeyDown(event: KeyboardEvent) { + if (items.length === 0) + return false + if (event.key === 'ArrowUp') { selectedIndex = ((selectedIndex + items.length) - 1) % items.length return true