Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,23 @@ function getSectionValueText(
switch (section.type) {
case 'month': {
if (section.contentType === 'digit') {
return adapter.format(adapter.setMonth(adapter.date(), Number(section.value) - 1), 'month');
const dateWithMonth = adapter.setMonth(adapter.date(), Number(section.value) - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LukasTy I'm not sure what the behavior should be when we try to generate the aria-valuetext of a value with invalid sections (for example 99 in the day).

Right now the PR removes the property.
Another approach would be to return the raw value of the section but I guess it doesn't add value compared to not setting the property.

return adapter.isValid(dateWithMonth) ? adapter.format(dateWithMonth, 'month') : '';
}
const parsedDate = adapter.parse(section.value, section.format);
return parsedDate ? adapter.format(parsedDate, 'month') : undefined;
return parsedDate && adapter.isValid(parsedDate)
? adapter.format(parsedDate, 'month')
: undefined;
}
case 'day':
return section.contentType === 'digit'
? adapter.format(
adapter.setDate(adapter.startOfYear(adapter.date()), Number(section.value)),
'dayOfMonthFull',
)
: section.value;
if (section.contentType === 'digit') {
const dateWithDay = adapter.setDate(
adapter.startOfYear(adapter.date()),
Number(section.value),
);
return adapter.isValid(dateWithDay) ? adapter.format(dateWithDay, 'dayOfMonthFull') : '';
}
return section.value;
case 'weekDay':
// TODO: improve by providing the label of the week day
return undefined;
Expand Down
Loading