From 4e1cd073e799b878db543286e4894f18cc318b77 Mon Sep 17 00:00:00 2001 From: Diego Nascimento Date: Wed, 14 Apr 2021 16:50:24 -0300 Subject: [PATCH] fix(@clayui/date-picker): When having a range and clicking on end date again the start date will be the same as the end date See: https://github.com/liferay/clay/pull/4008#issuecomment-819244473 --- packages/clay-date-picker/src/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/clay-date-picker/src/index.tsx b/packages/clay-date-picker/src/index.tsx index 6855b2fdc9..0127fb62f5 100644 --- a/packages/clay-date-picker/src/index.tsx +++ b/packages/clay-date-picker/src/index.tsx @@ -334,8 +334,13 @@ const ClayDatePicker: React.FunctionComponent = 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,