Skip to content

Commit

Permalink
fix(select): firing events properly in popover interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ciekawy authored and manucorporat committed May 3, 2017
1 parent 1902010 commit 59dd853
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/components/select/select-popover-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface SelectPopoverOption {
value: string;
disabled: boolean;
checked: boolean;
handler?: Function;
}

/** @hidden */
Expand All @@ -30,6 +31,10 @@ export class SelectPopover implements OnInit {
}

public set value(value: any) {
let checkedOption = this.options.find(option => option.value === value);
if (checkedOption && checkedOption.handler) {
checkedOption.handler();
}
this.viewController.dismiss(value);
}

Expand Down
12 changes: 5 additions & 7 deletions src/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ export class Select extends BaseInput<any> implements OnDestroy {
text: input.text,
checked: input.selected,
disabled: input.disabled,
value: input.value
value: input.value,
handler: () => {
this.value = input.value;
input.ionSelect.emit(input.value);
}
}));

overlay = new Popover(this._app, SelectPopover, {
Expand Down Expand Up @@ -368,12 +372,6 @@ export class Select extends BaseInput<any> implements OnDestroy {

overlay.onDidDismiss((value: any) => {
this._fireBlur();

if (this.interface === 'popover' && value) {
this.value = value;
this.ionChange.emit(value);
}

this._overlay = undefined;
});

Expand Down

0 comments on commit 59dd853

Please sign in to comment.