Skip to content
Permalink
Browse files

fix(datetime): avoid adding cancel and done button repeatedly

references #7333
  • Loading branch information...
brandyscarney committed Nov 8, 2017
1 parent 75cf887 commit 248a1cecedf4f607d467e3abff74650f9387f206
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/components/datetime/datetime.ts
@@ -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();

0 comments on commit 248a1ce

Please sign in to comment.
You can’t perform that action at this time.