@@ -1519,28 +1519,58 @@ describe('MatAutocomplete', () => {
1519
1519
expect ( panel . classList ) . toContain ( 'class-two' ) ;
1520
1520
} ) ) ;
1521
1521
1522
-
1523
- it ( 'should reset correctly when closed programmatically' , async ( ( ) => {
1522
+ it ( 'should reset correctly when closed programmatically' , fakeAsync ( ( ) => {
1524
1523
TestBed . overrideProvider ( MAT_AUTOCOMPLETE_SCROLL_STRATEGY , {
1525
1524
useFactory : ( overlay : Overlay ) => ( ) => overlay . scrollStrategies . close ( ) ,
1526
1525
deps : [ Overlay ]
1527
1526
} ) ;
1528
1527
1529
- const fixture = TestBed . createComponent ( SimpleAutocomplete ) ;
1528
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1530
1529
fixture . detectChanges ( ) ;
1531
1530
const trigger = fixture . componentInstance . trigger ;
1532
1531
1533
1532
trigger . openPanel ( ) ;
1534
1533
fixture . detectChanges ( ) ;
1534
+ zone . simulateZoneExit ( ) ;
1535
1535
1536
- fixture . whenStable ( ) . then ( ( ) => {
1537
- expect ( trigger . panelOpen ) . toBe ( true , 'Expected panel to be open.' ) ;
1536
+ expect ( trigger . panelOpen ) . toBe ( true , 'Expected panel to be open.' ) ;
1538
1537
1539
- scrolledSubject . next ( ) ;
1540
- fixture . detectChanges ( ) ;
1538
+ scrolledSubject . next ( ) ;
1539
+ fixture . detectChanges ( ) ;
1541
1540
1542
- expect ( trigger . panelOpen ) . toBe ( false , 'Expected panel to be closed.' ) ;
1543
- } ) ;
1541
+ expect ( trigger . panelOpen ) . toBe ( false , 'Expected panel to be closed.' ) ;
1542
+ } ) ) ;
1543
+
1544
+ it ( 'should be able to disable option ripples' , ( ) => {
1545
+ const fixture : ComponentFixture < SimpleAutocomplete > = createComponent ( SimpleAutocomplete ) ;
1546
+ fixture . detectChanges ( ) ;
1547
+
1548
+ expect ( fixture . componentInstance . options . toArray ( ) . every ( option => option . disableRipple ! ) )
1549
+ . toBe ( false , 'Expected option ripples to be enabled' ) ;
1550
+
1551
+ fixture . componentInstance . disableRipple = true ;
1552
+ fixture . detectChanges ( ) ;
1553
+
1554
+ expect ( fixture . componentInstance . options . toArray ( ) . every ( option => option . disableRipple ! ) )
1555
+ . toBe ( true , 'Expected option ripples to be disabled' ) ;
1556
+ } ) ;
1557
+
1558
+ it ( 'should not show option ripples if they were disabled' , fakeAsync ( ( ) => {
1559
+ const fixture : ComponentFixture < SimpleAutocomplete > = createComponent ( SimpleAutocomplete ) ;
1560
+
1561
+ fixture . componentInstance . disableRipple = true ;
1562
+ fixture . detectChanges ( ) ;
1563
+
1564
+ fixture . componentInstance . trigger . openPanel ( ) ;
1565
+ zone . simulateZoneExit ( ) ;
1566
+ fixture . detectChanges ( ) ;
1567
+
1568
+ const option = overlayContainerElement . querySelector ( 'mat-option' ) ! ;
1569
+
1570
+ dispatchFakeEvent ( option , 'mousedown' ) ;
1571
+ dispatchFakeEvent ( option , 'mouseup' ) ;
1572
+
1573
+ expect ( option . querySelectorAll ( '.mat-ripple-element' ) . length ) . toBe ( 0 ) ;
1544
1574
} ) ) ;
1545
1575
1546
1576
} ) ;
@@ -1672,7 +1702,8 @@ describe('MatAutocomplete', () => {
1672
1702
<input matInput placeholder="State" [matAutocomplete]="auto" [formControl]="stateCtrl">
1673
1703
</mat-form-field>
1674
1704
1675
- <mat-autocomplete class="class-one class-two" #auto="matAutocomplete" [displayWith]="displayFn">
1705
+ <mat-autocomplete class="class-one class-two" #auto="matAutocomplete"
1706
+ [displayWith]="displayFn" [disableRipple]="disableRipple">
1676
1707
<mat-option *ngFor="let state of filteredStates" [value]="state">
1677
1708
<span> {{ state.code }}: {{ state.name }} </span>
1678
1709
</mat-option>
@@ -1685,6 +1716,7 @@ class SimpleAutocomplete implements OnDestroy {
1685
1716
valueSub : Subscription ;
1686
1717
floatLabel = 'auto' ;
1687
1718
width : number ;
1719
+ disableRipple = false ;
1688
1720
1689
1721
@ViewChild ( MatAutocompleteTrigger ) trigger : MatAutocompleteTrigger ;
1690
1722
@ViewChild ( MatAutocomplete ) panel : MatAutocomplete ;
0 commit comments