Skip to content

Commit

Permalink
fix(@clayui/date-picker): When having a range and clicking on end dat…
Browse files Browse the repository at this point in the history
…e again the start date will be the same as the end date

See: #4008 (comment)
  • Loading branch information
diegonvs committed Apr 14, 2021
1 parent f6db982 commit 4e1cd07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/clay-date-picker/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,13 @@ const ClayDatePicker: React.FunctionComponent<IProps> = React.forwardRef<
let daysSelectedToString;

if (range) {
newDaysSelected =
date < startDate ? [date, endDate] : [startDate, date];
if (date === endDate) {
newDaysSelected = [date, date];
} else if (date < startDate) {
newDaysSelected = [date, endDate];
} else {
newDaysSelected = [startDate, date];
}

daysSelectedToString = fromRangeToString(
newDaysSelected,
Expand Down

0 comments on commit 4e1cd07

Please sign in to comment.