Repository navigation
fix(cdk/text-field): defer autosize checks until view initialization - #34136
Open
nagahara-naoki wants to merge 1 commit into
Open
nagahara-naoki wants to merge 1 commit into
nagahara-naoki wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Summary
CdkTextareaAutosizecan cache the textarea line height during its firstngDoCheck, before dynamic host classes have been applied. WithmatInputinsidemat-form-field, this means measuring the browser default font instead of the inherited font. The resulting minimum and maximum heights remain incorrect until a window resize clears the cache.Skip automatic checks until the view has initialized, allowing the existing
ngAfterViewInitresize to perform the initial measurement after host bindings have been applied.For example, a textarea with a 50px line height and limits of 2–5 rows now starts with
min-height: 100pxandmax-height: 250px.Fixes #33944.
Testing
Added regression tests for both a CDK textarea with a dynamic host class and a
matInputtextarea insidemat-form-field.pnpm bazel test //src/cdk/text-field:unit_tests_chromium //src/material/input:unit_tests_chromium --test_output=errors