Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

focus the textarea when the popup is visible

Abi Raja423c74bdc9e0
diff --git a/frontend/src/components/select-and-edit/EditPopup.tsx b/frontend/src/components/select-and-edit/EditPopup.tsx
index 5bc9d425..ca32e650 100644
--- a/frontend/src/components/select-and-edit/EditPopup.tsx
+++ b/frontend/src/components/select-and-edit/EditPopup.tsx
@@ -98,11 +98,16 @@ const EditPopup: React.FC<EditPopupProps> = ({
// 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
+ // because the textarea is not rendered yet)
+ useEffect(() => {
+ if (popupVisible) {
+ textareaRef.current?.focus();
+ }
+ }, [popupVisible]);
+
if (!popupVisible) return;
return (