Skip to content

Commit

Permalink
Improved fix for #6876 which caused a regression on item templates
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Nov 28, 2018
1 parent d050edd commit 03ecc9a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/components/selectbutton/selectbutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SelectButton implements ControlValueAccessor {
}

set options(val: any[]) {
let opts = this.optionLabel ? this.objectUtils.generateSelectItems(val, this.optionLabel) : val;
let opts = this.isSelectItems(val) ? val : this.objectUtils.generateSelectItems(val, this.optionLabel);
this._options = opts;
}

Expand All @@ -91,6 +91,19 @@ export class SelectButton implements ControlValueAccessor {
setDisabledState(val: boolean): void {
this.disabled = val;
}

isSelectItems(options) {
if (this.optionLabel) {
return false;
}
else if (options && options.length) {
let option = options[0];
return (option.hasOwnProperty('label') || option.hasOwnProperty('icon')) && option.hasOwnProperty('value');
}
else {
return false;
}
}

onItemClick(event, option: SelectItem, checkbox: HTMLInputElement, index: number) {
if(this.disabled || option.disabled) {
Expand Down

0 comments on commit 03ecc9a

Please sign in to comment.