Skip to content

Commit

Permalink
fix(datetime): avoid adding cancel and done button repeatedly
Browse files Browse the repository at this point in the history
references #7333
  • Loading branch information
brandyscarney committed Nov 8, 2017
1 parent 75cf887 commit 248a1ce
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,20 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni
// the user may have assigned some options specifically for the picker
const pickerOptions = {...this.pickerOptions};

// Configure picker under the hood
const picker = this._picker = this._pickerCtrl.create(pickerOptions);
picker.addButton({
// Add a cancel and done button by default to the picker
const defaultButtons = [{
text: this.cancelText,
role: 'cancel',
handler: () => this.ionCancel.emit(this)
});
picker.addButton({
}, {
text: this.doneText,
handler: (data: any) => this.value = data,
});
}];

pickerOptions.buttons = (pickerOptions.buttons || []).concat(defaultButtons);

// Configure picker under the hood
const picker = this._picker = this._pickerCtrl.create(pickerOptions);

picker.ionChange.subscribe(() => {
this.validate();
Expand Down

0 comments on commit 248a1ce

Please sign in to comment.