diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index 215b99a0340..f618cf5b88b 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -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', () => { diff --git a/src/lib/select/select.ts b/src/lib/select/select.ts index 259057a20a6..9d99134b0a3 100644 --- a/src/lib/select/select.ts +++ b/src/lib/select/select.ts @@ -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();