Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix Calendar duplicate today indicator (#4021)

Kevinjohn Gallagher25def2f10d28
diff --git a/.changeset/calendar-only-marks-in-month-date-cells-as-today-scd6.md b/.changeset/calendar-only-marks-in-month-date-cells-as-today-scd6.md
new file mode 100644
index 0000000000..d3dc8c21f0
--- /dev/null
+++ b/.changeset/calendar-only-marks-in-month-date-cells-as-today-scd6.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Calendar only marks in-month date cells as today, preventing duplicate today indicators in multi-month views.
+@Kevinjohn
diff --git a/packages/core/src/Calendar/dayCellUtils.test.ts b/packages/core/src/Calendar/dayCellUtils.test.ts
index 2e605b06e2..de8c3244dc 100644
--- a/packages/core/src/Calendar/dayCellUtils.test.ts
+++ b/packages/core/src/Calendar/dayCellUtils.test.ts
@@ -45,6 +45,11 @@ describe('computeDayCellState', () => {
expect(state.isToday).toBe(false);
});
+ it('does not identify an outside day as today', () => {
+ const state = computeDayCellState(makeInput({isOutside: true}));
+ expect(state.isToday).toBe(false);
+ });
+
it('identifies selected day in single mode', () => {
const state = computeDayCellState(
makeInput({selectedDate: plainDateFromISO('2024-03-15')}),
diff --git a/packages/core/src/Calendar/dayCellUtils.ts b/packages/core/src/Calendar/dayCellUtils.ts
index eecf88ecfd..5126681108 100644
--- a/packages/core/src/Calendar/dayCellUtils.ts
+++ b/packages/core/src/Calendar/dayCellUtils.ts
@@ -56,7 +56,7 @@ export function computeDayCellState(input: DayCellStateInput): DayCellState {
return {
effectivelyDisabled: isDisabled || isOutside,
- isToday: plainDateIsEqual(date, today),
+ isToday: !isOutside && plainDateIsEqual(date, today),
isSelected: !!(
!isOutside &&
mode === 'single' &&