From b13f0afc37fbead355d180099c94e70637e0aa51 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 4 May 2019 12:20:45 -0700 Subject: [PATCH] fix: fix autofocus in emoji dialog search (#1173) --- src/routes/_components/dialog/components/EmojiDialog.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/_components/dialog/components/EmojiDialog.html b/src/routes/_components/dialog/components/EmojiDialog.html index 959ac38..3a49d8a 100644 --- a/src/routes/_components/dialog/components/EmojiDialog.html +++ b/src/routes/_components/dialog/components/EmojiDialog.html @@ -173,7 +173,9 @@ if (!autoFocus) { return } - requestAnimationFrame(() => { + // The setTimeout is to work around timing issues where + // sometimes the search input isn't rendered yet. + setTimeout(() => requestAnimationFrame(() => { let container = this.refs.container if (container) { let searchInput = container.querySelector('emoji-mart .emoji-mart-search input') @@ -182,7 +184,7 @@ searchInput.focus() } } - }) + }), 50) } } }