Skip to content

fix: Resolve Component Render Error for chat input#1013

Merged
mfortman11 merged 1 commit into
mainfrom
component-render-error
Feb 25, 2026
Merged

fix: Resolve Component Render Error for chat input#1013
mfortman11 merged 1 commit into
mainfrom
component-render-error

Conversation

@mfortman11

@mfortman11 mfortman11 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

The bug: TextareaAutosize calls onHeightChange from a React layout effect on every render. The original code did onHeightChange={(height) => setTextareaHeight(height)}, which triggered a re-render on every call. Worse, textareaHeight controlled the layout (flex-row vs flex-col), which changed the available width, which changed the textarea's height, which fired onHeightChange again — creating an infinite render loop.

The fix: Removed onHeightChange and the textareaHeight state entirely. Instead, isMultiline is derived from two sources:

  • input.includes("\n") — detects explicit newlines (no state needed)
  • isWrapped state — detects visual wrapping, but only updated inside handleChange (user input events), never from a layout effect

This breaks the loop because handleChange only fires on actual user input, not on re-renders. Hysteresis prevents flickering at the boundary: expand when scrollHeight exceeds one line, but only collapse when text is under SAFE_SINGLE_LINE_CHARS characters.

Resolves #1012

@lucaseduoli lucaseduoli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work

@mfortman11 mfortman11 merged commit d824b59 into main Feb 25, 2026
3 checks passed
@edwinjosechittilappilly edwinjosechittilappilly added the bug 🔴 Something isn't working. label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔴 Something isn't working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Component Rendering issue caused by long text inputs to chat

3 participants