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]); };