An open source design system that's fully customizable and agent ready
TypeScript
fix(core): mark Calendar today cell with aria-current="date" (#3708)
Baraa Hamodif01eb102f312
diff --git a/.changeset/calendar-aria-current.md b/.changeset/calendar-aria-current.mdnew file mode 100644index 0000000000..2d34933bef--- /dev/null+++ b/.changeset/calendar-aria-current.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[fix] Calendar: mark today's date cell with `aria-current="date"`. Previously "today" was conveyed only visually, so screen-reader users could not identify the current date (WAI-ARIA date-picker pattern). (#3708)+@bhamodidiff --git a/packages/core/src/Calendar/Calendar.test.tsx b/packages/core/src/Calendar/Calendar.test.tsxindex 26e0ba5779..013d86a27b 100644--- a/packages/core/src/Calendar/Calendar.test.tsx+++ b/packages/core/src/Calendar/Calendar.test.tsx@@ -73,6 +73,24 @@ describe('Calendar', () => {expect(screen.getByText(expectedLabel)).toBeInTheDocument();});+ it("marks today's cell with aria-current='date'", () => {+ render(<Calendar />);++ const now = new Date();+ const iso = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;++ const todayCell = document.querySelector(`button[data-date="${iso}"]`);+ expect(todayCell).not.toBeNull();+ expect(todayCell).toHaveAttribute('aria-current', 'date');++ // Only today's cell is marked current.+ const others = Array.from(+ document.querySelectorAll('button[data-date]'),+ ).filter(el => el.getAttribute('data-date') !== iso);+ expect(others.length).toBeGreaterThan(0);+ others.forEach(el => expect(el).not.toHaveAttribute('aria-current'));+ });+it('displays day names', () => {render(<Calendar />);diff --git a/packages/core/src/Calendar/Calendar.tsx b/packages/core/src/Calendar/Calendar.tsxindex 163faf4bcb..48bbeea030 100644--- a/packages/core/src/Calendar/Calendar.tsx+++ b/packages/core/src/Calendar/Calendar.tsx@@ -972,6 +972,9 @@ function DayCell({data-date={day.iso}aria-label={plainDateFormat(date, DATE_FORMAT_WITH_WEEKDAY)}aria-disabled={state.effectivelyDisabled || undefined}+ // Mark today's cell programmatically (APG date-picker pattern), not just+ // visually, so screen-reader users can identify the current date.+ aria-current={state.isToday ? 'date' : undefined}disabled={isDisabled}// Initial roving tab-stop seed; useGridFocus owns it after mount.tabIndex={isTabbableDay ? 0 : -1}