Skip to content

Commit

Permalink
fix(select): don't open menu if there are no options (#2924)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and tinayuangao committed Feb 9, 2017
1 parent f29f7ab commit cc77ef4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cc77ef4

Please sign in to comment.