Skip to content

Commit 4ad2d96

Browse files
authored
fix(material-experimental/mdc-list): align ripple timings with MDC (#22396)
Uses the ripple timing values from MDC for our implementation so that it's consistent with the spec.
1 parent c45cd69 commit 4ad2d96

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/material-experimental/mdc-list/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ng_module(
3333
"@npm//@angular/core",
3434
"@npm//@angular/forms",
3535
"@npm//@material/list",
36+
"@npm//@material/ripple",
3637
],
3738
)
3839

@@ -92,6 +93,7 @@ ng_web_test_suite(
9293
name = "unit_tests",
9394
static_files = [
9495
"@npm//:node_modules/@material/list/dist/mdc.list.js",
96+
"@npm//:node_modules/@material/ripple/dist/mdc.ripple.js",
9597
],
9698
deps = [
9799
":list_tests_lib",

src/material-experimental/mdc-list/list-base.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
RippleTarget,
3030
setLines,
3131
} from '@angular/material-experimental/mdc-core';
32+
import {numbers} from '@material/ripple';
3233
import {Subscription} from 'rxjs';
3334
import {startWith} from 'rxjs/operators';
3435
import {MatListAvatarCssMatStyler, MatListIconCssMatStyler} from './list-styling';
@@ -91,8 +92,18 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
9192
private _listBase: MatListBase, private _platform: Platform,
9293
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
9394
globalRippleOptions?: RippleGlobalOptions) {
95+
// We have to clone the object, because we don't want to mutate a global value when we assign
96+
// the `animation` further down. The downside of doing this is that the ripple renderer won't
97+
// pick up dynamic changes to `disabled`, but it's not something we officially support.
98+
this.rippleConfig = {...(globalRippleOptions || {})};
9499
this._hostElement = this._elementRef.nativeElement;
95-
this.rippleConfig = globalRippleOptions || {};
100+
101+
if (!this.rippleConfig.animation) {
102+
this.rippleConfig.animation = {
103+
enterDuration: numbers.DEACTIVATION_TIMEOUT_MS,
104+
exitDuration: numbers.FG_DEACTIVATION_MS
105+
};
106+
}
96107

97108
if (!this._listBase._isNonInteractive) {
98109
this._initInteractiveListItem();

src/material-experimental/mdc-list/testing/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ng_web_test_suite(
4040
name = "unit_tests",
4141
static_files = [
4242
"@npm//:node_modules/@material/list/dist/mdc.list.js",
43+
"@npm//:node_modules/@material/ripple/dist/mdc.ripple.js",
4344
],
4445
deps = [
4546
":unit_tests_lib",

0 commit comments

Comments
 (0)