diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 5f57794bdd80..7f3e6ad47a6f 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -117,6 +117,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', () => { diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 1a3dabfd5fc6..872fd79079a8 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -266,7 +266,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();