Skip to content

Commit 4be7d15

Browse files
authored
fix(material-experimental/mdc-list): not accounting for global ripple options (#21393)
Fixes that the MDC-based list doesn't disable its ripples when they have been disabled globally.
1 parent ecb5663 commit 4be7d15

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ import {
1414
Directive,
1515
ElementRef,
1616
HostBinding,
17+
Inject,
1718
Input,
1819
NgZone,
1920
OnDestroy,
21+
Optional,
2022
QueryList
2123
} from '@angular/core';
2224
import {
25+
MAT_RIPPLE_GLOBAL_OPTIONS,
2326
RippleConfig,
27+
RippleGlobalOptions,
2428
RippleRenderer,
2529
RippleTarget,
2630
setLines,
@@ -74,17 +78,20 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
7478
* Implemented as part of `RippleTarget`.
7579
* @docs-private
7680
*/
77-
rippleConfig: RippleConfig = {};
81+
rippleConfig: RippleConfig & RippleGlobalOptions;
7882

7983
/**
8084
* Implemented as part of `RippleTarget`.
8185
* @docs-private
8286
*/
83-
get rippleDisabled(): boolean { return this.disableRipple; }
87+
get rippleDisabled(): boolean { return this.disableRipple || !!this.rippleConfig.disabled; }
8488

8589
constructor(public _elementRef: ElementRef<HTMLElement>, protected _ngZone: NgZone,
86-
private _listBase: MatListBase, private _platform: Platform) {
90+
private _listBase: MatListBase, private _platform: Platform,
91+
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
92+
globalRippleOptions?: RippleGlobalOptions) {
8793
this._hostElement = this._elementRef.nativeElement;
94+
this.rippleConfig = globalRippleOptions || {};
8895

8996
if (!this._listBase._isNonInteractive) {
9097
this._initInteractiveListItem();

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ import {
2121
NgZone,
2222
OnDestroy,
2323
OnInit,
24+
Optional,
2425
QueryList,
2526
ViewChild,
2627
ViewEncapsulation
2728
} from '@angular/core';
28-
import {MatLine, ThemePalette} from '@angular/material-experimental/mdc-core';
29+
import {
30+
MatLine,
31+
MAT_RIPPLE_GLOBAL_OPTIONS,
32+
RippleGlobalOptions,
33+
ThemePalette,
34+
} from '@angular/material-experimental/mdc-core';
2935
import {MatListBase, MatListItemBase} from './list-base';
3036
import {LIST_OPTION, ListOption, MatListOptionCheckboxPosition} from './list-option-types';
3137

@@ -125,8 +131,9 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit
125131
ngZone: NgZone,
126132
platform: Platform,
127133
@Inject(SELECTION_LIST) public _selectionList: SelectionList,
128-
private _changeDetectorRef: ChangeDetectorRef) {
129-
super(element, ngZone, _selectionList, platform);
134+
private _changeDetectorRef: ChangeDetectorRef,
135+
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalRippleOptions?: RippleGlobalOptions) {
136+
super(element, ngZone, _selectionList, platform, globalRippleOptions);
130137

131138
// By default, we mark all options as unselected. The MDC list foundation will
132139
// automatically update the attribute based on selection. Note that we need to

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ import {
1212
Component,
1313
ContentChildren,
1414
ElementRef,
15+
Inject,
1516
NgZone,
17+
Optional,
1618
QueryList,
1719
ViewChild,
1820
ViewEncapsulation
1921
} from '@angular/core';
20-
import {MatLine} from '@angular/material-experimental/mdc-core';
22+
import {
23+
MatLine,
24+
MAT_RIPPLE_GLOBAL_OPTIONS,
25+
RippleGlobalOptions,
26+
} from '@angular/material-experimental/mdc-core';
2127
import {MatListBase, MatListItemBase} from './list-base';
2228

2329
@Component({
@@ -52,7 +58,12 @@ export class MatListItem extends MatListItemBase {
5258
QueryList<ElementRef<Element>>;
5359
@ViewChild('text') _itemText: ElementRef<HTMLElement>;
5460

55-
constructor(element: ElementRef, ngZone: NgZone, listBase: MatListBase, platform: Platform) {
56-
super(element, ngZone, listBase, platform);
61+
constructor(
62+
element: ElementRef,
63+
ngZone: NgZone,
64+
listBase: MatListBase,
65+
platform: Platform,
66+
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) globalRippleOptions?: RippleGlobalOptions) {
67+
super(element, ngZone, listBase, platform, globalRippleOptions);
5768
}
5869
}

0 commit comments

Comments
 (0)