Skip to content

Commit

Permalink
Merge branch 'master' into X2-10202
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyDevico authored Aug 27, 2024
2 parents 5a9599f + 82b7a88 commit c30a029
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xola/ui-kit",
"version": "2.3.10",
"version": "2.3.11",
"description": "Xola UI Kit",
"license": "MIT",
"repository": {
Expand Down
14 changes: 11 additions & 3 deletions src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,17 @@ export const DatePicker = ({
const to = toDate(now(day, timezoneName).endOf("day"), false);

onChange({ from, to }, options, event);
} else if (DateUtils.isDayBefore(value.from, toDate(now(day, timezoneName)))) {
} else if (value.from && DateUtils.isDayBefore(value.from, toDate(now(day, timezoneName)))) {
// this works if the user first clicked on the date that will go to "from", and the second click to "to"
onChange(
DateUtils.addDayToRange(toDate(now(day, timezoneName).endOf("day"), false), value),
options,
event,
);
} else if (
DateUtils.isDayAfter(value.from, toDate(now(day, timezoneName))) ||
DateUtils.isSameDay(value.from, toDate(now(day, timezoneName)))
value.from &&
(DateUtils.isDayAfter(value.from, toDate(now(day, timezoneName))) ||
DateUtils.isSameDay(value.from, toDate(now(day, timezoneName))))
) {
// this works if the user first clicked on the date that will go to "to", and the second click to "from"
// also this works when the user has selected one date
Expand All @@ -166,6 +167,13 @@ export const DatePicker = ({
options,
event,
);
} else {
// Fallback when value.from is null
onChange(
DateUtils.addDayToRange(toDate(now(day, timezoneName).endOf("day"), false), value),
options,
event,
);
}
} else {
onChange(toDate(now(day, timezoneName)), options, event);
Expand Down

0 comments on commit c30a029

Please sign in to comment.