Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const DatePicker = ({
components = {},
getTooltip,
upcomingDates,
shouldSelectFutureDatesInRelativeRange = true,
...rest
}) => {
const initialValue = variant === variants.single ? value : value.from;
Expand Down Expand Up @@ -87,7 +88,15 @@ export const DatePicker = ({

const handleRelativeRangeChanged = (rangeName, range) => {
setCurrentMonth(range.from);
onChange(range, modifiers, null);
const newRange = { ...range };
if (
!shouldSelectFutureDatesInRelativeRange && // don't select future dates, e.g. for cash flow report
range.to.isAfter(dayjs().get("date"))
) {
newRange.to = dayjs().get("date");
}

onChange(newRange, modifiers, null);
Comment on lines +91 to +99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will not work. Did you mean to use dayjs().toDate() instead of dayjs().get("date")?

dayjs().get("date") just returns a number of the current day in month.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I feel like this logic belongs to x2-seller and not ui-kit. We can discuss when you are free

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah needs to be changed, not sure how it was working when I checked.

};

const handleMonthChange = (m) => {
Expand Down