Skip to content

Commit 96a2eb7

Browse files
committed
wip select tests
1 parent 075f337 commit 96a2eb7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/lib/select/select.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,20 +1629,22 @@ fdescribe('MdSelect', () => {
16291629
`Expected trigger label to align along x-axis, accounting for the padding in rtl.`);
16301630
}));
16311631

1632-
fit('should not adjust if all options are within a group, except the selected one',
1633-
fakeAsync(() => {
1632+
it('should not adjust if all options are within a group, except the selected one',
1633+
async(() => {
16341634
groupFixture.componentInstance.control.setValue('mime-11');
16351635
groupFixture.detectChanges();
16361636

16371637
trigger.click();
16381638
groupFixture.detectChanges();
16391639

1640-
const selected = document.querySelector('.cdk-overlay-pane md-option.mat-selected')!;
1641-
const selectedOptionLeft = selected.getBoundingClientRect().left;
1642-
const triggerLeft = trigger.getBoundingClientRect().left;
1640+
fixture.whenStable().then(() => {
1641+
const selected = document.querySelector('.cdk-overlay-pane md-option.mat-selected')!;
1642+
const selectedOptionLeft = selected.getBoundingClientRect().left;
1643+
const triggerLeft = trigger.getBoundingClientRect().left;
16431644

1644-
// 16px is the default option padding
1645-
expect(Math.floor(selectedOptionLeft)).toEqual(Math.floor(triggerLeft - 16));
1645+
// 16px is the default option padding
1646+
expect(Math.floor(selectedOptionLeft)).toEqual(Math.floor(triggerLeft - 16));
1647+
});
16461648
}));
16471649

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

src/lib/select/select.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
ViewportRuler
4949
} from '@angular/cdk/overlay';
5050
import {merge} from 'rxjs/observable/merge';
51+
import {first} from 'rxjs/operator/first';
5152
import {Observable} from 'rxjs/Observable';
5253
import {Subscription} from 'rxjs/Subscription';
5354
import {fadeInContent, transformPanel, transformPlaceholder} from './select-animations';
@@ -661,8 +662,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
661662
* Callback that is invoked when the overlay panel has been attached.
662663
*/
663664
_onAttached(): void {
664-
this._calculateOverlayOffsetX();
665-
this._setScrollTop();
665+
first.call(this.overlayDir.positionChange).subscribe(() => {
666+
this._calculateOverlayOffsetX();
667+
this._setScrollTop();
668+
});
666669
}
667670

668671
/** Whether the select has a value. */

0 commit comments

Comments
 (0)