fix(cdk/text-field): autosize measure scrollHeight with stable wrapping width #32612
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.
Fix cdkTextareaAutosize height under-measurement when the textarea’s wrapping width changes, which could result in clipped content
Fixes 32192
Problem
CdkTextareaAutosizetemporarily applies the measuring CSS class (cdk-textarea-autosize-measuring*) while readingscrollHeight. That class changesbox-sizingand horizontal padding, which can change the effective wrapping width. When wrapping changes during measurement,scrollHeightcan be underestimated, leaving the renderedtextareatoo short by one or more line.Solution
textarea’s content width (clientWidthminus horizontal padding) before applying the measuring class.style.widthto that captured content width so wrapping stays identical to the renderedtextarea.Tests
Added a regression test that uses padding +
box-sizing: border-boxand a wrapping-sensitive value to ensure the measured height matchesscrollHeight.Impact