|
1 |
| -import { Component, ContentChildren, DebugElement, ViewChild } from '@angular/core'; |
| 1 | +import { Component, ContentChildren, DebugElement, ViewChild, OnInit } from '@angular/core'; |
2 | 2 | import { async, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
3 | 3 | import { By } from '@angular/platform-browser';
|
4 | 4 | import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
|
@@ -29,7 +29,8 @@ describe('IgxDropDown ', () => {
|
29 | 29 | IgxDropDownTestScrollComponent,
|
30 | 30 | IgxDropDownTestDisabledComponent,
|
31 | 31 | IgxDropDownTestDisabledAnyComponent,
|
32 |
| - IgxDropDownTestEmptyListComponent |
| 32 | + IgxDropDownTestEmptyListComponent, |
| 33 | + IgxDropDownWithScrollComponent |
33 | 34 | ],
|
34 | 35 | imports: [
|
35 | 36 | IgxDropDownModule,
|
@@ -807,6 +808,19 @@ describe('IgxDropDown ', () => {
|
807 | 808 | expect(igxDropDown.collapsed).toEqual(true);
|
808 | 809 | });
|
809 | 810 | }));
|
| 811 | + |
| 812 | + it('#1663 drop down flickers on open', () => { |
| 813 | + const fixture = TestBed.createComponent(IgxDropDownWithScrollComponent); |
| 814 | + fixture.detectChanges(); |
| 815 | + const button = fixture.debugElement.query(By.css('button')).nativeElement; |
| 816 | + const igxDropDown = fixture.componentInstance.dropdownScroll; |
| 817 | + button.click(); |
| 818 | + igxDropDown.open(); |
| 819 | + fixture.whenStable().then(() => { |
| 820 | + fixture.detectChanges(); |
| 821 | + expect((<any>igxDropDown).toggleDirective.element.scrollTop).toEqual(44); |
| 822 | + }); |
| 823 | + }); |
810 | 824 | });
|
811 | 825 |
|
812 | 826 | @Component({
|
@@ -997,3 +1011,35 @@ class IgxDropDownTestEmptyListComponent {
|
997 | 1011 | this.dropdownEmpty.toggle();
|
998 | 1012 | }
|
999 | 1013 | }
|
| 1014 | +@Component({ |
| 1015 | + template: ` |
| 1016 | + <button (click)="selectItem5()">Select 5</button> |
| 1017 | + <igx-drop-down #scrollDropDown> |
| 1018 | + <igx-drop-down-item *ngFor="let item of items"> |
| 1019 | + {{ item.field }} |
| 1020 | + </igx-drop-down-item> |
| 1021 | + </igx-drop-down> |
| 1022 | + ` |
| 1023 | +}) |
| 1024 | +class IgxDropDownWithScrollComponent implements OnInit { |
| 1025 | + |
| 1026 | + @ViewChild('scrollDropDown', { read: IgxDropDownComponent }) |
| 1027 | + public dropdownScroll: IgxDropDownComponent; |
| 1028 | + |
| 1029 | + public items: any[] = []; |
| 1030 | + |
| 1031 | + public toggleDropDown() { |
| 1032 | + this.dropdownScroll.toggle(); |
| 1033 | + } |
| 1034 | + |
| 1035 | + public selectItem5() { |
| 1036 | + this.dropdownScroll.setSelectedItem(4); |
| 1037 | + } |
| 1038 | + |
| 1039 | + ngOnInit() { |
| 1040 | + this.dropdownScroll.height = '200px'; |
| 1041 | + for (let index = 1; index < 100; index++) { |
| 1042 | + this.items.push({ field: 'Item ' + index }); |
| 1043 | + } |
| 1044 | + } |
| 1045 | +} |
0 commit comments