Skip to content

Commit f6e8584

Browse files
authoredFeb 28, 2024··
perf(material/form-field): resolve scrolling performance issues (#27251)
MDC was setting `will-change` on a couple of elements which caused significant scrolling performance issues on pages with a lot of form fields. These changes reset the `will-change`, because one of the elements wasn't being animated at all and the other one was only animating `transform` which is hardware-accelerated. Fixes #27249.
1 parent 76b4ea1 commit f6e8584

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎src/material/form-field/_mdc-text-field-structure-overrides.scss

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
@use '../core/tokens/token-utils';
55
@use '../core/style/vendor-prefixes';
66

7+
// TODO(b/263527625): should be removed when this is addressed on the MDC side.
8+
// MDC sets a will-change on this element, because of the animation. This can cause
9+
// scrolling performance degradation on pages with a lot of form fields so we reset it.
10+
// The animation is on a `transform` which is hardware-accelerated already.
11+
// This flag is used to re-add the `will-change` internally since removing it causes a
12+
// lot of screenshot diffs.
13+
$_enable-form-field-will-change-reset: true;
14+
715
// Mixin that can be included to override the default MDC text-field
816
// styles to fit our needs. See individual comments for context on why
917
// certain MDC styles need to be modified.
@@ -36,6 +44,10 @@
3644
// and makes migration from the legacy form-field easier for tests that were depending on
3745
// clicking the label to focus the input.
3846
pointer-events: all;
47+
48+
@if ($_enable-form-field-will-change-reset) {
49+
will-change: auto;
50+
}
3951
}
4052

4153
.mat-mdc-form-field:not(.mat-form-field-disabled) .mat-mdc-floating-label.mdc-floating-label {
@@ -68,6 +80,10 @@
6880
.mat-mdc-text-field-wrapper {
6981
height: auto;
7082
flex: auto;
83+
84+
@if ($_enable-form-field-will-change-reset) {
85+
will-change: auto;
86+
}
7187
}
7288

7389
// The icon prefix/suffix is closer to the edge of the form-field than the infix is in a

0 commit comments

Comments
 (0)
Please sign in to comment.