Skip to content

Commit bdfadeb

Browse files
jelbourncrisbeto
authored andcommitted
wip select tests
1 parent 355d851 commit bdfadeb

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/lib/select/select.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,20 +1715,22 @@ describe('MatSelect', () => {
17151715
`Expected trigger label to align along x-axis, accounting for the padding in rtl.`);
17161716
}));
17171717

1718-
fit('should not adjust if all options are within a group, except the selected one',
1719-
fakeAsync(() => {
1718+
it('should not adjust if all options are within a group, except the selected one',
1719+
async(() => {
17201720
groupFixture.componentInstance.control.setValue('mime-11');
17211721
groupFixture.detectChanges();
17221722

17231723
trigger.click();
17241724
groupFixture.detectChanges();
17251725

1726-
const selected = document.querySelector('.cdk-overlay-pane mat-option.mat-selected')!;
1727-
const selectedOptionLeft = selected.getBoundingClientRect().left;
1728-
const triggerLeft = trigger.getBoundingClientRect().left;
1726+
fixture.whenStable().then(() => {
1727+
const selected = document.querySelector('.cdk-overlay-pane mat-option.mat-selected')!;
1728+
const selectedOptionLeft = selected.getBoundingClientRect().left;
1729+
const triggerLeft = trigger.getBoundingClientRect().left;
17291730

1730-
// 16px is the default option padding
1731-
expect(Math.floor(selectedOptionLeft)).toEqual(Math.floor(triggerLeft - 16));
1731+
// 16px is the default option padding
1732+
expect(Math.floor(selectedOptionLeft)).toEqual(Math.floor(triggerLeft - 16));
1733+
});
17321734
}));
17331735

17341736
it('should align the first option to the trigger, if nothing is selected', async(() => {

src/lib/select/select.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,10 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
640640
* Callback that is invoked when the overlay panel has been attached.
641641
*/
642642
_onAttached(): void {
643-
this._calculateOverlayOffsetX();
644-
this._setScrollTop();
643+
first.call(this.overlayDir.positionChange).subscribe(() => {
644+
this._calculateOverlayOffsetX();
645+
this._setScrollTop();
646+
});
645647
}
646648

647649
/** Returns the theme to be used on the panel. */

0 commit comments

Comments
 (0)