Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeRangePicker error fix #14600 #14653

Closed
Closed
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 @@ -292,16 +292,16 @@ export const adjustSectionValue = <TDate extends PickerValidDate, TSection exten
if (newSectionValueNumber > sectionBoundaries.maximum) {
return getCleanValue(
sectionBoundaries.minimum +
((newSectionValueNumber - sectionBoundaries.maximum - 1) %
(sectionBoundaries.maximum - sectionBoundaries.minimum + 1)),
((newSectionValueNumber - sectionBoundaries.maximum - 1) %
(sectionBoundaries.maximum - sectionBoundaries.minimum + 1)),
);
}

if (newSectionValueNumber < sectionBoundaries.minimum) {
return getCleanValue(
sectionBoundaries.maximum -
((sectionBoundaries.minimum - newSectionValueNumber - 1) %
(sectionBoundaries.maximum - sectionBoundaries.minimum + 1)),
((sectionBoundaries.minimum - newSectionValueNumber - 1) %
(sectionBoundaries.maximum - sectionBoundaries.minimum + 1)),
);
}

Expand Down Expand Up @@ -487,9 +487,8 @@ export const getDateFromDateSections = <TDate extends PickerValidDate>(
export const createDateStrForV7HiddenInputFromSections = (sections: FieldSection[]) =>
sections
.map((section) => {
return `${section.startSeparator}${section.value || section.placeholder}${
section.endSeparator
}`;
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator
}`;
})
.join('');

Expand Down Expand Up @@ -817,7 +816,8 @@ export const parseSelectedSections = (
}

if (typeof selectedSections === 'string') {
return sections.findIndex((section) => section.type === selectedSections);
const index = sections.findIndex((section) => section.type === selectedSections);
return index === -1 ? null : index;
}

return selectedSections;
Expand All @@ -841,9 +841,9 @@ export const getSectionValueText = <TDate extends PickerValidDate>(
case 'day':
return section.contentType === 'digit'
? utils.format(
utils.setDate(utils.startOfYear(utils.date()), Number(section.value)),
'dayOfMonthFull',
)
utils.setDate(utils.startOfYear(utils.date()), Number(section.value)),
'dayOfMonthFull',
)
: section.value;
case 'weekDay':
// TODO: improve by providing the label of the week day
Expand Down
Loading