From e3e25e11441bdc08337d0af5cf4970f61f891c85 Mon Sep 17 00:00:00 2001 From: blckfalcon <12796172+blckfalcon@users.noreply.github.com> Date: Wed, 26 Feb 2020 23:09:19 -0300 Subject: [PATCH] Fix focus on CompositionInput (#3973) --- ts/components/hooks.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ts/components/hooks.ts b/ts/components/hooks.ts index 8b19ffe50..1506683cc 100644 --- a/ts/components/hooks.ts +++ b/ts/components/hooks.ts @@ -18,9 +18,13 @@ export const useRestoreFocus = ( } return () => { - if (lastFocused && lastFocused.focus) { - lastFocused.focus(); - } + // This ensures that the focus is returned to + // previous element + setTimeout(() => { + if (lastFocused && lastFocused.focus) { + lastFocused.focus(); + } + }); }; }, [focusRef, root]); };