From 5f3868f3c9d894a3ef5b2dece862e84e7dfd6622 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Fri, 31 May 2024 18:36:11 -0400 Subject: [PATCH] fix bug with focusing textarea --- frontend/src/components/select-and-edit/EditPopup.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/select-and-edit/EditPopup.tsx b/frontend/src/components/select-and-edit/EditPopup.tsx index ca32e65..5b70813 100644 --- a/frontend/src/components/select-and-edit/EditPopup.tsx +++ b/frontend/src/components/select-and-edit/EditPopup.tsx @@ -98,10 +98,14 @@ const EditPopup: React.FC = ({ // Reset the update text setUpdateText(""); + + // Focus the textarea + textareaRef.current?.focus(); }, [event, iframeRef]); - // Focus the textarea when the popup is visible (we can't do this when handling the click event + // Focus the textarea when the popup is visible (we can't do this only when handling the click event // because the textarea is not rendered yet) + // We need to also do it in the click event because popupVisible doesn't change values in that event useEffect(() => { if (popupVisible) { textareaRef.current?.focus();