Skip to content

Commit 9106377

Browse files
committed
perf(material/form-field): resolve scrolling performance issues
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 5c3cbb6 commit 9106377

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
// and makes migration from the legacy form-field easier for tests that were depending on
3030
// clicking the label to focus the input.
3131
pointer-events: all;
32+
33+
// TODO(b/286481557): should be removed when this is addressed on the MDC side.
34+
// MDC sets a will-change on this element, because of the animation. This can cause
35+
// scrolling performance degradation on pages with a lot of form fields so we reset it.
36+
// The animation is on a `transform` which is hardware-accelerated already.
37+
will-change: auto;
3238
}
3339

3440
// Reset the height that MDC sets on native input elements. We cannot rely on their
@@ -56,6 +62,11 @@
5662
.mat-mdc-text-field-wrapper {
5763
height: auto;
5864
flex: auto;
65+
66+
// TODO(b/286481557): should be removed when this is addressed on the MDC side.
67+
// MDC sets a will-change on this element, despite it not animating. This can cause
68+
// scrolling performance degradation on pages with a lot of form fields so we reset it.
69+
will-change: auto;
5970
}
6071

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

0 commit comments

Comments
 (0)