From 248a1cecedf4f607d467e3abff74650f9387f206 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Wed, 8 Nov 2017 12:55:05 -0500 Subject: [PATCH] fix(datetime): avoid adding cancel and done button repeatedly references #7333 --- src/components/datetime/datetime.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/datetime/datetime.ts b/src/components/datetime/datetime.ts index 86bc98bacca..35f33a3d963 100644 --- a/src/components/datetime/datetime.ts +++ b/src/components/datetime/datetime.ts @@ -525,17 +525,20 @@ export class DateTime extends BaseInput 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();