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

fix(datepicker): adds Optional chaining #18046

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Changes from 2 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 @@ -81,7 +81,7 @@
if (inputTo === target && fp.selectedDates[1]) {
// Using getTime() enables the ability to more readily compare the date currently
// selected in the calendar and the date currently in the value of the input
const withoutTime = (date) => date.setHours(0, 0, 0, 0);
const withoutTime = (date) => date?.setHours(0, 0, 0, 0);

Check warning on line 84 in packages/react/src/components/DatePicker/plugins/fixEventsPlugin.js

View check run for this annotation

Codecov / codecov/patch

packages/react/src/components/DatePicker/plugins/fixEventsPlugin.js#L84

Added line #L84 was not covered by tests
const selectedToDate = withoutTime(new Date(fp.selectedDates[1]));
const currentValueToDate = withoutTime(
parseDateWithFormat(inputTo.value)
Expand All @@ -104,7 +104,7 @@
}
}

const isValidDate = (date) => date.toString() !== 'Invalid Date';
const isValidDate = (date) => date?.toString() !== 'Invalid Date';
// save end date in calendar inmediately after it's been written down
if (inputTo === target && fp.selectedDates.length === 1 && inputTo.value) {
if (isValidDate(parseDateWithFormat(inputTo.value))) {
Expand Down
Loading