|
1 | 1 | import {Direction, Directionality} from '@angular/cdk/bidi';
|
2 | 2 | import {DOWN_ARROW, ENTER, ESCAPE, SPACE, UP_ARROW, TAB} from '@angular/cdk/keycodes';
|
3 |
| -import {OverlayContainer} from '@angular/cdk/overlay'; |
| 3 | +import {OverlayContainer, Overlay} from '@angular/cdk/overlay'; |
4 | 4 | import {map} from 'rxjs/operators/map';
|
5 | 5 | import {startWith} from 'rxjs/operators/startWith';
|
6 | 6 | import {ScrollDispatcher} from '@angular/cdk/scrolling';
|
@@ -45,6 +45,7 @@ import {
|
45 | 45 | MatAutocompleteModule,
|
46 | 46 | MatAutocompleteSelectedEvent,
|
47 | 47 | MatAutocompleteTrigger,
|
| 48 | + MAT_AUTOCOMPLETE_SCROLL_STRATEGY, |
48 | 49 | } from './index';
|
49 | 50 |
|
50 | 51 |
|
@@ -1519,6 +1520,29 @@ describe('MatAutocomplete', () => {
|
1519 | 1520 | }));
|
1520 | 1521 |
|
1521 | 1522 |
|
| 1523 | + it('should reset correctly when closed programmatically', async(() => { |
| 1524 | + TestBed.overrideProvider(MAT_AUTOCOMPLETE_SCROLL_STRATEGY, { |
| 1525 | + useFactory: (overlay: Overlay) => () => overlay.scrollStrategies.close(), |
| 1526 | + deps: [Overlay] |
| 1527 | + }); |
| 1528 | + |
| 1529 | + const fixture = TestBed.createComponent(SimpleAutocomplete); |
| 1530 | + fixture.detectChanges(); |
| 1531 | + const trigger = fixture.componentInstance.trigger; |
| 1532 | + |
| 1533 | + trigger.openPanel(); |
| 1534 | + fixture.detectChanges(); |
| 1535 | + |
| 1536 | + fixture.whenStable().then(() => { |
| 1537 | + expect(trigger.panelOpen).toBe(true, 'Expected panel to be open.'); |
| 1538 | + |
| 1539 | + scrolledSubject.next(); |
| 1540 | + fixture.detectChanges(); |
| 1541 | + |
| 1542 | + expect(trigger.panelOpen).toBe(false, 'Expected panel to be closed.'); |
| 1543 | + }); |
| 1544 | + })); |
| 1545 | + |
1522 | 1546 | });
|
1523 | 1547 |
|
1524 | 1548 | it('should have correct width when opened', () => {
|
|
0 commit comments