File tree Expand file tree Collapse file tree 1 file changed +7
-16
lines changed
packages/react-grab/src/components/selection-label Expand file tree Collapse file tree 1 file changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -173,21 +173,6 @@ export const SelectionLabel: Component<SelectionLabelProps> = (props) => {
173173 const elementIdentity = ( ) =>
174174 `${ props . tagName ?? "" } :${ props . componentName ?? "" } ` ;
175175
176- createEffect ( ( ) => {
177- if ( props . isPromptMode && inputRef && props . onSubmit ) {
178- // HACK: Defer focus one tick so the textarea is fully mounted.
179- const focusTimeout = setTimeout ( ( ) => {
180- if ( inputRef ) {
181- inputRef . focus ( ) ;
182- autoResizeTextarea ( inputRef , TEXTAREA_MAX_HEIGHT_PX ) ;
183- }
184- } , 0 ) ;
185- onCleanup ( ( ) => {
186- clearTimeout ( focusTimeout ) ;
187- } ) ;
188- }
189- } ) ;
190-
191176 const positionComputation = createMemo (
192177 ( previousResult : PositionResult ) : PositionResult => {
193178 viewportVersion ( ) ;
@@ -618,7 +603,13 @@ export const SelectionLabel: Component<SelectionLabelProps> = (props) => {
618603 style = { { "padding-left" : props . replyToPrompt ? "14px" : "0" } }
619604 >
620605 < textarea
621- ref = { inputRef }
606+ ref = { ( element ) => {
607+ inputRef = element ;
608+ if ( props . onSubmit ) {
609+ element . focus ( ) ;
610+ autoResizeTextarea ( element , TEXTAREA_MAX_HEIGHT_PX ) ;
611+ }
612+ } }
622613 data-react-grab-ignore-events
623614 data-react-grab-input
624615 class = "text-black text-[13px] leading-4 font-medium bg-transparent border-none outline-none resize-none flex-1 p-0 m-0 wrap-break-word overflow-y-auto"
You can’t perform that action at this time.
0 commit comments