Repository navigation
Replace the composer's JS autosize with native field-sizing - #384
Merged
Merged
Conversation
The composer textarea sized itself with a one-shot layout effect: reset height to auto, read scrollHeight, clamp to 42-160px, re-running only when the draft text changed. A scrollHeight read is only as good as the layout at the instant it runs - any mount under a transient layout (an emulated viewport resized after load, a zoom or DPI change) bakes a wrong height in until the next keystroke. field-sizing: content on the textarea tracks the content continuously with the same 42-160px bounds (textareas are border-box in Chromium's UA sheet, so min/max-height match the old JS range exactly). The effect, the ref it existed for, and the useLayoutEffect/useRef imports are removed; the skip-link target is the element id and is unchanged. Same native-autosize posture the code-sandbox card's inputs already use. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The composer textarea sized itself with a one-shot layout effect: reset
heighttoauto, readscrollHeight, clamp to 42-160px, re-running only when the draft text changed. AscrollHeightread is only as good as the layout at the instant it runs, so any mount under a transient layout - a viewport resized after load, a zoom or DPI change - baked a wrong height into the inline style, and nothing corrected it until the next keystroke. In the failure mode this fix was traced from, an empty one-row composer rendered pinned at the 160px ceiling.Change
field-sizing: contenton.composer-input, withmin-height: 42px/max-height: 160px/overflow-y: auto. The height now tracks the content continuously instead of being sampled once, so it cannot go stale. Textareas areborder-boxin Chromium's UA sheet, so the bounds match the old JS 42-160 range exactly; this is the same native-autosize posture the code-sandbox card's inputs already use. The layout effect, the ref that existed only for it, and the now-unuseduseLayoutEffect/useRefimports are removed; the skip-link jump target is the element id and is unchanged.Test plan
Composer.test.tsx: 38 pass unchanged.npm run check(schema drift, typecheck, lint, vitest, build, bundle size) against a clean checkout of this branch: 2135 pass.