mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore(autocomplete): switch to OnPush change detection (#5546)
* Switches `md-autocomplete` to `OnPush` change detection. * Fixes a newly-introduced test failure. Relates to #5035.
This commit is contained in:
committed by
mmalerba
parent
9ab0c90493
commit
ae5bca261a
@@ -763,17 +763,19 @@ describe('MdAutocomplete', () => {
|
||||
.toEqual(32, `Expected panel to reveal the sixth option.`);
|
||||
}));
|
||||
|
||||
it('should scroll to active options on UP arrow', fakeAsync(() => {
|
||||
tick();
|
||||
const scrollContainer =
|
||||
document.querySelector('.cdk-overlay-pane .mat-autocomplete-panel')!;
|
||||
it('should scroll to active options on UP arrow', async(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
const scrollContainer =
|
||||
document.querySelector('.cdk-overlay-pane .mat-autocomplete-panel')!;
|
||||
|
||||
fixture.componentInstance.trigger._handleKeydown(UP_ARROW_EVENT);
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.trigger._handleKeydown(UP_ARROW_EVENT);
|
||||
fixture.detectChanges();
|
||||
|
||||
// Expect option bottom minus the panel height (528 - 256 = 272)
|
||||
expect(scrollContainer.scrollTop).toEqual(272, `Expected panel to reveal last option.`);
|
||||
fixture.whenStable().then(() => {
|
||||
// Expect option bottom minus the panel height (528 - 256 = 272)
|
||||
expect(scrollContainer.scrollTop).toEqual(272, `Expected panel to reveal last option.`);
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not scroll to active options that are fully in the panel', fakeAsync(() => {
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
ViewChild,
|
||||
ViewEncapsulation,
|
||||
ChangeDetectorRef,
|
||||
ChangeDetectionStrategy,
|
||||
} from '@angular/core';
|
||||
import {MdOption} from '../core';
|
||||
import {ActiveDescendantKeyManager} from '../core/a11y/activedescendant-key-manager';
|
||||
@@ -35,6 +36,7 @@ export type AutocompletePositionY = 'above' | 'below';
|
||||
templateUrl: 'autocomplete.html',
|
||||
styleUrls: ['autocomplete.css'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
exportAs: 'mdAutocomplete',
|
||||
host: {
|
||||
'class': 'mat-autocomplete'
|
||||
|
||||
Reference in New Issue
Block a user