@@ -1486,6 +1486,39 @@ describe('MatAutocomplete', () => {
1486
1486
} ) ) ;
1487
1487
1488
1488
1489
+ it ( 'should be able to disable option ripples' , ( ) => {
1490
+ const fixture : ComponentFixture < SimpleAutocomplete > = createComponent ( SimpleAutocomplete ) ;
1491
+ fixture . detectChanges ( ) ;
1492
+
1493
+ expect ( fixture . componentInstance . options . toArray ( ) . every ( option => option . disableRipple ! ) )
1494
+ . toBe ( false , 'Expected option ripples to be enabled' ) ;
1495
+
1496
+ fixture . componentInstance . disableRipple = true ;
1497
+ fixture . detectChanges ( ) ;
1498
+
1499
+ expect ( fixture . componentInstance . options . toArray ( ) . every ( option => option . disableRipple ! ) )
1500
+ . toBe ( true , 'Expected option ripples to be disabled' ) ;
1501
+ } ) ;
1502
+
1503
+ it ( 'should not show option ripples if they were disabled' , fakeAsync ( ( ) => {
1504
+ const fixture : ComponentFixture < SimpleAutocomplete > = createComponent ( SimpleAutocomplete ) ;
1505
+
1506
+ fixture . componentInstance . disableRipple = true ;
1507
+ fixture . detectChanges ( ) ;
1508
+
1509
+ fixture . componentInstance . trigger . openPanel ( ) ;
1510
+ zone . simulateZoneExit ( ) ;
1511
+ fixture . detectChanges ( ) ;
1512
+
1513
+ const option = overlayContainerElement . querySelector ( 'mat-option' ) ! ;
1514
+
1515
+ dispatchFakeEvent ( option , 'mousedown' ) ;
1516
+ dispatchFakeEvent ( option , 'mouseup' ) ;
1517
+
1518
+ expect ( option . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
1519
+ } ) ) ;
1520
+
1521
+
1489
1522
} ) ;
1490
1523
1491
1524
it ( 'should have correct width when opened' , ( ) => {
@@ -1615,7 +1648,8 @@ describe('MatAutocomplete', () => {
1615
1648
<input matInput placeholder="State" [matAutocomplete]="auto" [formControl]="stateCtrl">
1616
1649
</mat-form-field>
1617
1650
1618
- <mat-autocomplete class="class-one class-two" #auto="matAutocomplete" [displayWith]="displayFn">
1651
+ <mat-autocomplete class="class-one class-two" #auto="matAutocomplete"
1652
+ [displayWith]="displayFn" [disableRipple]="disableRipple">
1619
1653
<mat-option *ngFor="let state of filteredStates" [value]="state">
1620
1654
<span> {{ state.code }}: {{ state.name }} </span>
1621
1655
</mat-option>
@@ -1628,6 +1662,7 @@ class SimpleAutocomplete implements OnDestroy {
1628
1662
valueSub : Subscription ;
1629
1663
floatLabel = 'auto' ;
1630
1664
width : number ;
1665
+ disableRipple = false ;
1631
1666
1632
1667
@ViewChild ( MatAutocompleteTrigger ) trigger : MatAutocompleteTrigger ;
1633
1668
@ViewChild ( MatAutocomplete ) panel : MatAutocomplete ;
0 commit comments