fix(select): don't open menu if there are no options (#2924)

Currently the select will attempt to show it's menu when there are no options, which ends up looking like a slight box shadow that shows up above it. This change prevents the menu from opening at all if it's empty.
This commit is contained in:
Kristiyan Kostadinov
2017-02-09 19:32:42 +01:00
committed by tinayuangao
parent f29f7ab8ed
commit cc77ef422b
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -125,6 +125,16 @@ describe('MdSelect', () => {
});
}));
it('should not attempt to open a select that does not have any options', () => {
fixture.componentInstance.foods = [];
fixture.detectChanges();
trigger.click();
fixture.detectChanges();
expect(fixture.componentInstance.select.panelOpen).toBe(false);
});
});
describe('selection logic', () => {
+1 -1
View File
@@ -268,7 +268,7 @@ export class MdSelect implements AfterContentInit, ControlValueAccessor, OnDestr
/** Opens the overlay panel. */
open(): void {
if (this.disabled) {
if (this.disabled || !this.options.length) {
return;
}
this._calculateOverlayPosition();