From b46d4fbd737523aa54753699f6fb65e3e35af9ca Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 26 Sep 2025 12:11:41 -0600 Subject: [PATCH] extended refer --- .../components/ui/inputs/InputTextArea.tsx | 25 +++++++++++-------- .../ui/inputs/InputTextAreaButton.tsx | 6 ++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/web/src/components/ui/inputs/InputTextArea.tsx b/apps/web/src/components/ui/inputs/InputTextArea.tsx index 146597ec0..4e8831c98 100644 --- a/apps/web/src/components/ui/inputs/InputTextArea.tsx +++ b/apps/web/src/components/ui/inputs/InputTextArea.tsx @@ -28,7 +28,7 @@ export interface InputTextAreaProps onPressEnter?: (e: React.KeyboardEvent) => void; } -export interface InputTextAreaRef { +export interface InputTextAreaRef extends HTMLTextAreaElement { forceRecalculateHeight: () => void; } @@ -50,15 +50,20 @@ export const InputTextArea = React.forwardRef ({ - forceRecalculateHeight: () => { - if (textareaRef.current) { - // Force a recalculation by triggering an input event - const event = new Event('input', { bubbles: true }); - textareaRef.current.dispatchEvent(event); - } - }, - }), + () => { + if (!textareaRef.current) { + return null as unknown as InputTextAreaRef; + } + return Object.assign(textareaRef.current, { + forceRecalculateHeight: () => { + if (textareaRef.current) { + // Force a recalculation by triggering an input event + const event = new Event('input', { bubbles: true }); + textareaRef.current.dispatchEvent(event); + } + }, + }); + }, [] ); diff --git a/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx b/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx index e9fca6c76..9df7f2b31 100644 --- a/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx +++ b/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx @@ -4,7 +4,7 @@ import { cn } from '@/lib/classMerge'; import { Button } from '../buttons/Button'; import ShapeSquare from '../icons/NucleoIconFilled/shape-square'; import { ArrowUp } from '../icons/NucleoIconOutlined'; -import { InputTextArea, type InputTextAreaProps } from './InputTextArea'; +import { InputTextArea, type InputTextAreaProps, type InputTextAreaRef } from './InputTextArea'; const inputTextAreaButtonVariants = cva( 'relative flex flex-col w-full items-center overflow-visible rounded-xl cursor-text border border-border transition-all duration-200', @@ -29,7 +29,7 @@ export interface InputTextAreaButtonProps extends Omit( +export const InputTextAreaButton = forwardRef( ( { className, @@ -51,7 +51,7 @@ export const InputTextAreaButton = forwardRef { const onSubmitPreflight = () => { if (disabled) return; - const text = (textRef as React.RefObject).current?.value || ''; + const text = (textRef as React.RefObject).current?.value || ''; onSubmit(text); };