mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
tinayuangao
parent
f29f7ab8ed
commit
cc77ef422b
@@ -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', () => {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user