From 54c6091af96727af58dcc83f3ca96ef6c78a6cf7 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 24 Oct 2023 13:59:29 +0100 Subject: [PATCH] Focus textarea after a timeout (#15408) GitOrigin-RevId: 468cc27a6fd0a677858906ee67d872bc0b64529d --- .../js/shared/components/auto-expanding-text-area.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/shared/components/auto-expanding-text-area.tsx b/services/web/frontend/js/shared/components/auto-expanding-text-area.tsx index b278727171..c6968f2330 100644 --- a/services/web/frontend/js/shared/components/auto-expanding-text-area.tsx +++ b/services/web/frontend/js/shared/components/auto-expanding-text-area.tsx @@ -111,8 +111,10 @@ function AutoExpandingTextArea({ resetHeight() if (autoFocus) { const cursorPos = el.value.length - el.focus() - el.setSelectionRange(cursorPos, cursorPos) + window.setTimeout(() => { + el.focus() + el.setSelectionRange(cursorPos, cursorPos) + }, 100) } }, [autoFocus, resetHeight])