File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
src/components/NcEmojiPicker Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ This component allows the user to pick an emoji.
195195
196196<script >
197197import { Picker , Emoji , EmojiIndex } from ' emoji-mart-vue-fast'
198+ import { isFocusable } from ' tabbable'
198199import { t } from ' ../../l10n.js'
199200import { getCurrentSkinTone , setCurrentSkinTone } from ' ../../functions/emoji/emoji.ts'
200201import { useTrapStackControl } from ' ../../composables/useTrapStackControl.ts'
@@ -408,7 +409,10 @@ export default {
408409
409410 afterHide () {
410411 // Manually return focus to the trigger button, as we disabled focus-trap
411- this .$refs .popover .$el .querySelector (' button, [role="button"]' )? .focus ()
412+ // But only if there is no focus target outside the picker, for example, input element that received focus by click closing the emoji picker
413+ if (! document .activeElement || this .$refs .picker .$el .contains (document .activeElement ) || ! isFocusable (document .activeElement )) {
414+ this .$refs .popover .$el .querySelector (' button, [role="button"]' )? .focus ()
415+ }
412416 },
413417
414418 /**
You can’t perform that action at this time.
0 commit comments