From cd4bdf63813666f5dcea722e8f3b688a503a4109 Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Mon, 27 Jan 2025 15:50:28 +0100 Subject: [PATCH 1/3] fix(NcEmojiPicker): arrow navigation Signed-off-by: Grigorii K. Shartsev --- .../NcEmojiPicker/NcEmojiPicker.vue | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/components/NcEmojiPicker/NcEmojiPicker.vue b/src/components/NcEmojiPicker/NcEmojiPicker.vue index 52480cb40e..1d7d08527c 100644 --- a/src/components/NcEmojiPicker/NcEmojiPicker.vue +++ b/src/components/NcEmojiPicker/NcEmojiPicker.vue @@ -147,6 +147,11 @@ This component allows the user to pick an emoji. trailing-button-icon="close" :trailing-button-label="t('Clear search')" :show-trailing-button="search !== ''" + @keydown.left="callPickerArrowHandlerWithScrollFix('onArrowLeft', $event)" + @keydown.right="callPickerArrowHandlerWithScrollFix('onArrowRight', $event)" + @keydown.down="callPickerArrowHandlerWithScrollFix('onArrowDown', $event)" + @keydown.up="callPickerArrowHandlerWithScrollFix('onArrowUp', $event)" + @keydown.enter="$refs.picker.onEnter" @trailing-button-click="clearSearch(); slotProps.onSearch(search);" @update:value="slotProps.onSearch(search)" /> 's handlers with scroll bug fix + * @param {'onArrowLeft' | 'onArrowRight' | 'onArrowDown' | 'onArrowUp'} originalHandlerName - Picker's arrow keydown handler name + * @param {KeyboardEvent} event - Keyboard event + */ + async callPickerArrowHandlerWithScrollFix(originalHandlerName, event) { + // Call the original handler + // See: https://github.com/serebrov/emoji-mart-vue/blob/a1ea72673a111cce78dc8caad8bc9ea3e02ad5bd/src/components/Picker.vue#L29 + // TODO: expose these methods via slot props in upstream library + this.$refs.picker[originalHandlerName](event) + + // Wait until emoji-mart-vue-fast scrolls + await this.$nextTick() + + // Scroll position is incorrect after emoji-mart-vue-fast scrolls... + // It calculates scroll incorrectly. + // It doesn't take into account, that emojis are wrapped into categories sections + // See: https://github.com/serebrov/emoji-mart-vue/blob/a1ea72673a111cce78dc8caad8bc9ea3e02ad5bd/src/utils/picker.js#L244 + // Now scroll to the correct position + // TODO: fix in upstream + const selectedEmoji = this.$refs.picker.$el.querySelector('.emoji-mart-emoji-selected') + selectedEmoji?.scrollIntoView({ + block: 'center', + inline: 'center', + }) + }, }, } From 16c596f396dd9add97f21d5834a4dfd181928928 Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Mon, 27 Jan 2025 16:50:17 +0100 Subject: [PATCH 2/3] fix(NcEmojiPicker): skip emoji on Tab navigation Signed-off-by: Grigorii K. Shartsev --- .../NcEmojiPicker/NcEmojiPicker.vue | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/src/components/NcEmojiPicker/NcEmojiPicker.vue b/src/components/NcEmojiPicker/NcEmojiPicker.vue index 1d7d08527c..5366dc0ae8 100644 --- a/src/components/NcEmojiPicker/NcEmojiPicker.vue +++ b/src/components/NcEmojiPicker/NcEmojiPicker.vue @@ -107,10 +107,12 @@ This component allows the user to pick an emoji.