Skip to content

Commit 69d990f

Browse files
authored
Fix in CalendarCell for date range selection (#1887)
## 📝 Changes Fix in CalendarCell for date range selection. Date range was no longer getting selected, the check never returned the proper boolean to actually set the value. Updated to no longer have custom handling (not sure how it was working before really) and just allow the underlying react-aria to handle the selection. ## ✅ Checklist Easy UI has certain UX standards that must be met. In general, non-trivial changes should meet the following criteria: - [X] Visuals match Design Specs in Figma - [X] Stories accompany any component changes - [X] Code is in accordance with our style guide - [X] Design tokens are utilized - [X] Unit tests accompany any component changes - [X] TSDoc is written for any API surface area - [X] Specs are up-to-date - [X] Console is free from warnings - [X] No accessibility violations are reported - [X] Cross-browser check is performed (Chrome, Safari, Firefox) - [X] Changeset is added
1 parent 9f93e28 commit 69d990f

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

.changeset/open-friends-fall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@easypost/easy-ui": patch
3+
---
4+
5+
Fixes CalendarCell date range selection

easy-ui-react/src/Calendar/CalendarCell.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,31 @@ export function CalendarCell({ state, date }: CalendarCellProps) {
3030
} = useCalendarCell({ date }, state, ref);
3131
const isRangeCalendar = has(state, "highlightedRange");
3232
const rangeState = state as unknown as RangeCalendarState;
33-
const singleState = state as unknown as CalendarState;
3433
const isNextMonth = date.compare(state.visibleRange.end) > 0;
3534
const isPreviousMonth = date.compare(state.visibleRange.start) < 0;
3635

37-
const handleMonthNavigation = () => {
38-
if (state.isDisabled || isUnavailable || state.isReadOnly) return;
39-
if (isNextMonth && !isUnavailable) {
36+
const handleMonthNavigation = (e: React.MouseEvent<HTMLDivElement>) => {
37+
// Handle month navigation for dates outside current month
38+
if (
39+
isNextMonth &&
40+
!isUnavailable &&
41+
!state.isDisabled &&
42+
!state.isReadOnly
43+
) {
4044
state.focusNextPage();
41-
}
42-
if (isPreviousMonth && !isUnavailable) {
45+
} else if (
46+
isPreviousMonth &&
47+
!isUnavailable &&
48+
!state.isDisabled &&
49+
!state.isReadOnly
50+
) {
4351
state.focusPreviousPage();
4452
}
45-
if (!state.isInvalid(date)) {
46-
if (isRangeCalendar) {
47-
if (!rangeState.anchorDate) {
48-
rangeState.setValue(rangeState.highlightedRange);
49-
}
50-
} else {
51-
singleState.setValue(date);
52-
}
53+
54+
// Call react-aria's onClick handler to properly handle date selection
55+
if (buttonProps.onClick) {
56+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
57+
buttonProps.onClick(e as any);
5358
}
5459
};
5560

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)