From ae750ce26dbb7746e023789f6e3dcc0d5cc01bd5 Mon Sep 17 00:00:00 2001 From: Joe Attardi Date: Sun, 23 Aug 2020 20:04:32 -0400 Subject: [PATCH] Fix scroll jumping when showing picker --- src/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5c8c7fc6..98ecf871 100644 --- a/src/index.ts +++ b/src/index.ts @@ -473,16 +473,16 @@ export class EmojiButton { this.focusTrap.activate(); - const initialFocusElement = this.pickerEl.querySelector( - this.options.showSearch && this.options.autoFocusSearch - ? `.${CLASS_SEARCH_FIELD}` - : `.${CLASS_EMOJI}[tabindex="0"]` - ) as HTMLElement; - initialFocusElement.focus(); - setTimeout(() => { document.addEventListener('click', this.onDocumentClick); document.addEventListener('keydown', this.onDocumentKeydown); + + const initialFocusElement = this.pickerEl.querySelector( + this.options.showSearch && this.options.autoFocusSearch + ? `.${CLASS_SEARCH_FIELD}` + : `.${CLASS_EMOJI}[tabindex="0"]` + ) as HTMLElement; + initialFocusElement.focus(); }); this.emojiArea.reset();