fix(web): re-measure a textarea whose height was computed before layout - #1680
Open
takke1986 wants to merge 1 commit into
Open
fix(web): re-measure a textarea whose height was computed before layout#1680takke1986 wants to merge 1 commit into
takke1986 wants to merge 1 commit into
Conversation
The auto-size effect runs once on mount and depends on the value. When it runs before the element has been laid out - which is what happens inside the dialog that ModalSystemContext renders - scrollHeight is 0, so the height is set to 0px. A textarea whose value never changes afterwards keeps that height forever and its content is hidden behind overflow-y: hidden. This is invisible in development because StrictMode invokes the effect twice and the second run happens after layout, which is why it only reproduces in a deployed build. Observe the element and re-measure whenever its box changes, so the height catches up once the element is laid out. Also add the border back to the computed height: scrollHeight covers the content and the padding but not the border, while the assigned height is interpreted as the full border box. Measured in the modal with StrictMode disabled, matching a production build: before height=0px clientHeight=12 scrollHeight=36 after height=38px clientHeight=36 scrollHeight=36
takke1986
force-pushed
the
fix/textarea-autosize-border
branch
from
August 22, 2026 15:02
4d4f219 to
21e89c5
Compare
Contributor
Author
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.




Description of Changes
The auto-size effect in
Textarearuns on mount and depends on the value:When it runs before the element has been laid out,
scrollHeightis 0, so the height isset to
0px. That is what happens inside the dialogModalSystemContextrenders. Becausethe effect only depends on the value, a textarea whose value never changes afterwards keeps
height: 0pxforever, andoverflow-y: hiddenhides the content.This is invisible in development.
main.tsxwraps the tree inReact.StrictMode, whichinvokes effects twice, and the second run happens after layout and repairs the height. In a
production build the effect runs once, so the modal stays broken — which is why #1171
reproduces on a deployed environment but not with
npm run dev.Measured
I rendered
ModalSystemContextin isolation and measured it in a headless browser, togglingStrictModeto reproduce a production build:style.heightclientHeightscrollHeightThe
0pxrow is the bug, and it matches the screenshot in #1171.The fix
ResizeObserverand re-measure whenever its box changes, sothe height catches up once the element is laid out. A re-entrancy guard keeps the observer
from reacting to the height it sets itself
scrollHeightcovers the content and thepadding but not the border, while the assigned
heightis interpreted as the full borderbox because Tailwind sets
box-sizing: border-box(this is the 2px in the table above)Scope:
Textareais used in 13 places, but only ones whose value never changes aftermount can get stuck; everywhere else the height is recomputed on each keystroke, which is
why this has not been noticed more widely.
ModalSystemContextis used byChatPage,RagKnowledgeBasePageandSharedChatPage, so the RAG chat is affected too.Compatibility: no API change. Textareas that were already sized correctly get 2px taller
(the border); ones that were stuck at
0pxnow size to their content.Checklist
comments next to the calculation)
npm run cdk:test— no changes underpackages/cdk, snapshots unaffectedAlso run:
npm run web:test— 278 passedeslintandprettier --checkcleanRelated Issues