mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(datetime): enable custom day values (#9708)
* fix(datetime): dayValues attribute fixes #7190 * fix(datetime): default to the first year if the current year doesn't exist When the current year does not exist in yearValues, it was disabling months when it shouldn’t - this commit fixes that so all of the months are enabled. Closes #7190 * fix(datetime): only set the year to the first option if yearCol exists
This commit is contained in:
@ -594,9 +594,15 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
|
||||
let monthOpt: PickerColumnOption;
|
||||
let dayOpt: PickerColumnOption;
|
||||
|
||||
// default to assuming today's year
|
||||
let selectedYear = today.getFullYear();
|
||||
// default to the current year
|
||||
let selectedYear: number = today.getFullYear();
|
||||
|
||||
if (yearCol) {
|
||||
// default to the first value if the current year doesn't exist in the options
|
||||
if (!yearCol.options.find(col => col.value === today.getFullYear())) {
|
||||
selectedYear = yearCol.options[0].value;
|
||||
}
|
||||
|
||||
yearOpt = yearCol.options[yearCol.selectedIndex];
|
||||
if (yearOpt) {
|
||||
// they have a selected year value
|
||||
@ -639,7 +645,7 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
|
||||
if (isPresent(selectedMonth)) {
|
||||
// enable/disable which days are valid
|
||||
// to show within the min/max date range
|
||||
for (i = 0; i < 31; i++) {
|
||||
for (i = 0; i < dayCol.options.length; i++) {
|
||||
dayOpt = dayCol.options[i];
|
||||
|
||||
// loop through each day and see if it
|
||||
@ -653,7 +659,7 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
|
||||
|
||||
} else {
|
||||
// enable/disable which numbers of days to show in this month
|
||||
for (i = 0; i < 31; i++) {
|
||||
for (i = 0; i < dayCol.options.length; i++) {
|
||||
dayCol.options[i].disabled = (numDaysInMonth <= i);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user