fix(datetime): recalculate day column when month or year is changed (#17815)

Co-Authored-By: KillerCodeMonkey<bengtler@gmail.com>
Co-Authored-By: olivercodes <boliver@linux.com>
Co-Authored-By: liamdebeasi <liamdebeasi@users.noreply.github.com>
This commit is contained in:
Liam DeBeasi
2019-03-21 08:51:06 -04:00
committed by GitHub
parent aca78f5ac6
commit 9273f97a0c
6 changed files with 302 additions and 1 deletions

View File

@ -261,11 +261,36 @@ export class Datetime implements ComponentInterface {
const pickerOptions = this.generatePickerOptions();
const picker = await this.pickerCtrl.create(pickerOptions);
this.isExpanded = true;
picker.onDidDismiss().then(() => {
this.isExpanded = false;
this.setFocus();
});
picker.addEventListener('ionPickerColChange', async (event: any) => {
const data = event.detail;
/**
* Don't bother checking for non-dates as things like hours or minutes
* are always going to have the same number of column options
*/
if (data.name !== 'month' && data.name !== 'day' && data.name !== 'year') { return; }
const colSelectedIndex = data.selectedIndex;
const colOptions = data.options;
const changeData: any = {};
changeData[data.name] = {
value: colOptions[colSelectedIndex].value
};
this.updateDatetimeValue(changeData);
const columns = this.generateColumns();
picker.columns = columns;
await this.validate(picker);
});
await this.validate(picker);
await picker.present();
}
@ -300,6 +325,7 @@ export class Datetime implements ComponentInterface {
text: this.cancelText,
role: 'cancel',
handler: () => {
this.updateDatetimeValue(this.value);
this.ionCancel.emit();
}
},