Skip to content

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

Python

Place cursor at end of textarea when refocused after error

Abi Raja0397bd487627
diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsx
index 928e5be4..d8594fd7 100644
--- a/frontend/src/components/sidebar/Sidebar.tsx
+++ b/frontend/src/components/sidebar/Sidebar.tsx
@@ -189,7 +189,9 @@ function Sidebar({
(appState === AppState.CODE_READY || isSelectedVariantComplete) &&
textareaRef.current
) {
- textareaRef.current.focus();
+ const el = textareaRef.current;
+ el.focus();
+ el.setSelectionRange(el.value.length, el.value.length);
}
}, [appState, isSelectedVariantComplete]);