Skip to content

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

TypeScript

fix(core): TreeList, Pagination dots and Calendar days use aria-disabled (#7887)

Cindy Zhangcde6233de78d
diff --git a/.changeset/composites-focusable-disabled.md b/.changeset/composites-focusable-disabled.md
new file mode 100644
index 0000000000..f294cc39e3
--- /dev/null
+++ b/.changeset/composites-focusable-disabled.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Disabled TreeList rows' expand toggle and action button, disabled Pagination dots and disabled Calendar days no longer render the native `disabled` attribute. Each exposes `aria-disabled="true"` instead, so a disabled Calendar day or Pagination dot can take focus and be announced as disabled, while clicks, Enter and Space still do nothing and arrow keys still skip disabled days as before. This meets the focusable-disabled requirement in spec:AST-085 (FR1, FR2). No API changes.
+
+@cixzhang
diff --git a/packages/core/src/Calendar/Calendar.test.tsx b/packages/core/src/Calendar/Calendar.test.tsx
index 4bb769a328..5271f7429b 100644
--- a/packages/core/src/Calendar/Calendar.test.tsx
+++ b/packages/core/src/Calendar/Calendar.test.tsx
@@ -382,25 +382,35 @@ describe('Calendar', () => {
// ─── Date Constraints ────────────────────────────────────────
it('respects min date constraint', () => {
- render(<Calendar focusDate="2026-01-01" min="2026-01-10" />);
+ const onChange = vi.fn();
+ render(
+ <Calendar focusDate="2026-01-01" min="2026-01-10" onChange={onChange} />,
+ );
// Day 5 should be disabled (before min)
const day5 = getDayButton(5);
- expect(day5).toBeDisabled();
+ expect(day5).toHaveAttribute('aria-disabled', 'true');
+ // spec:AST-085 FR1: focusable through aria-disabled, not natively disabled;
+ // a click still selects nothing.
+ expect(day5).not.toHaveAttribute('disabled');
+ day5.focus();
+ expect(day5).toHaveFocus();
+ day5.click();
+ expect(onChange).not.toHaveBeenCalled();
// Day 15 should be enabled (after min)
const day15 = getDayButton(15);
- expect(day15).not.toBeDisabled();
+ expect(day15).not.toHaveAttribute('aria-disabled', 'true');
});
it('respects max date constraint', () => {
render(<Calendar focusDate="2026-01-01" max="2026-01-20" />);
const day25 = getDayButton(25);
- expect(day25).toBeDisabled();
+ expect(day25).toHaveAttribute('aria-disabled', 'true');
const day15 = getDayButton(15);
- expect(day15).not.toBeDisabled();
+ expect(day15).not.toHaveAttribute('aria-disabled', 'true');
});
// ─── Initial Visible Month ───────────────────────────────────
@@ -424,14 +434,20 @@ describe('Calendar', () => {
render(<Calendar min="2027-03-04" max="2027-06-30" />);
expect(screen.getByText('March 2027')).toBeInTheDocument();
- expect(getDayButton(4, 'March', 2027)).not.toBeDisabled();
+ expect(getDayButton(4, 'March', 2027)).not.toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
});
it('opens on max when the window is entirely in the past', () => {
render(<Calendar min="2019-01-01" max="2019-04-30" />);
expect(screen.getByText('April 2019')).toBeInTheDocument();
- expect(getDayButton(30, 'April', 2019)).not.toBeDisabled();
+ expect(getDayButton(30, 'April', 2019)).not.toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
});
it('keeps max in the last pane in the two-month layout', () => {
@@ -466,7 +482,7 @@ describe('Calendar', () => {
// January 4, 2026 is a Sunday - should be disabled
const sunday = getDayButton(4);
- expect(sunday).toBeDisabled();
+ expect(sunday).toHaveAttribute('aria-disabled', 'true');
});
it('caps the end date to maxRangeSpan once a start is picked', async () => {
@@ -475,15 +491,43 @@ describe('Calendar', () => {
render(<Calendar mode="range" focusDate="2026-01-01" maxRangeSpan={7} />);
// Before a start is picked every day is selectable.
- expect(getDayButton(20)).not.toBeDisabled();
+ expect(getDayButton(20)).not.toHaveAttribute('aria-disabled', 'true');
// Pick Jan 10 as the start. A 7-day window spans Jan 4–16 (start ± 6).
await user.click(getDayButton(10));
- expect(getDayButton(16)).not.toBeDisabled(); // 6 days after — the edge
- expect(getDayButton(17)).toBeDisabled(); // 7 days after — beyond the cap
- expect(getDayButton(4)).not.toBeDisabled(); // 6 days before — symmetric
- expect(getDayButton(3)).toBeDisabled(); // 7 days before — beyond the cap
+ expect(getDayButton(16)).not.toHaveAttribute('aria-disabled', 'true'); // 6 days after — the edge
+ expect(getDayButton(17)).toHaveAttribute('aria-disabled', 'true'); // 7 days after — beyond the cap
+ expect(getDayButton(4)).not.toHaveAttribute('aria-disabled', 'true'); // 6 days before — symmetric
+ expect(getDayButton(3)).toHaveAttribute('aria-disabled', 'true'); // 7 days before — beyond the cap
+ });
+
+ it('keeps one Tab stop when the span cap disables the day that held it', async () => {
+ const user = userEvent.setup();
+
+ render(<Calendar mode="range" focusDate="2026-01-01" maxRangeSpan={7} />);
+
+ // Arrow from Jan 1 to Jan 25 so Jan 25 holds the grid's Tab stop.
+ getDayButton(1).focus();
+ await user.keyboard('{ArrowDown}{ArrowDown}{ArrowDown}');
+ for (let i = 0; i < 3; i += 1) {
+ await user.keyboard('{ArrowRight}');
+ }
+ expect(getDayButton(25)).toHaveFocus();
+
+ // Picking Jan 10 as the start disables Jan 25 (beyond the 7-day cap).
+ await user.click(getDayButton(10));
+ expect(getDayButton(25)).toHaveAttribute('aria-disabled', 'true');
+
+ // spec:AST-085 FR1: a disabled day stays focusable but never keeps the
+ // grid's Tab stop, so the grid still has exactly one, on an enabled day.
+ const grid = screen.getByRole('grid');
+ const stops = Array.from(
+ grid.querySelectorAll<HTMLElement>('button[data-date][tabindex="0"]'),
+ );
+ expect(stops).toHaveLength(1);
+ expect(stops[0]).not.toHaveAttribute('aria-disabled', 'true');
+ expect(getDayButton(25)).toHaveAttribute('tabindex', '-1');
});
it('enforces minRangeSpan once a start is picked', async () => {
@@ -496,11 +540,11 @@ describe('Calendar', () => {
// The picked start itself stays enabled — it is the active selection
// anchor, not an unreachable end.
- expect(getDayButton(10)).not.toBeDisabled();
- expect(getDayButton(11)).toBeDisabled(); // 1 day apart — too short
- expect(getDayButton(12)).not.toBeDisabled(); // 3-day span — allowed
- expect(getDayButton(8)).not.toBeDisabled(); // 3-day span the other way
- expect(getDayButton(9)).toBeDisabled(); // 2-day span — too short
+ expect(getDayButton(10)).not.toHaveAttribute('aria-disabled', 'true');
+ expect(getDayButton(11)).toHaveAttribute('aria-disabled', 'true'); // 1 day apart — too short
+ expect(getDayButton(12)).not.toHaveAttribute('aria-disabled', 'true'); // 3-day span — allowed
+ expect(getDayButton(8)).not.toHaveAttribute('aria-disabled', 'true'); // 3-day span the other way
+ expect(getDayButton(9)).toHaveAttribute('aria-disabled', 'true'); // 2-day span — too short
});
it('commits a same-day range with the default minimum', async () => {
@@ -565,8 +609,8 @@ describe('Calendar', () => {
// …and the start is cleared: the days that minRangeSpan disabled around
// the old anchor are selectable again, so a new start can be placed there.
- expect(getDayButton(11)).not.toBeDisabled();
- expect(getDayButton(9)).not.toBeDisabled();
+ expect(getDayButton(11)).not.toHaveAttribute('aria-disabled', 'true');
+ expect(getDayButton(9)).not.toHaveAttribute('aria-disabled', 'true');
});
it('announces the cleared range in the provider locale', async () => {
@@ -603,7 +647,7 @@ describe('Calendar', () => {
// A picked single date must not disable far-away days.
await user.click(getDayButton(10));
- expect(getDayButton(25)).not.toBeDisabled();
+ expect(getDayButton(25)).not.toHaveAttribute('aria-disabled', 'true');
});
it('keeps a controlled value that is wider than maxRangeSpan (selection-only)', () => {
@@ -621,7 +665,7 @@ describe('Calendar', () => {
// No selection is in progress (both endpoints are set), so no anchor →
// every day is pickable and both endpoints render selected.
- expect(getDayButton(20)).not.toBeDisabled();
+ expect(getDayButton(20)).not.toHaveAttribute('aria-disabled', 'true');
expect(getDayButton(5).closest('[role="gridcell"]')).toHaveAttribute(
'aria-selected',
'true',
@@ -1713,7 +1757,7 @@ describe('Calendar', () => {
render(<Calendar focusDate="2026-01-01" min="2026-01-05" />);
const day1 = getDayButton(1);
- expect(day1).toBeDisabled();
+ expect(day1).toHaveAttribute('aria-disabled', 'true');
const day8 = getDayButton(8);
day8.focus();
@@ -1741,7 +1785,7 @@ describe('Calendar', () => {
render(<Calendar focusDate="2026-01-01" dateConstraints={[disableJan8]} />);
const day8 = getDayButton(8);
- expect(day8).toBeDisabled();
+ expect(day8).toHaveAttribute('aria-disabled', 'true');
const day15 = getDayButton(15);
day15.focus();
diff --git a/packages/core/src/Calendar/Calendar.tsx b/packages/core/src/Calendar/Calendar.tsx
index 9726349a8e..79b92b41ee 100644
--- a/packages/core/src/Calendar/Calendar.tsx
+++ b/packages/core/src/Calendar/Calendar.tsx
@@ -1372,7 +1372,8 @@ function DayCell({
// 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}
+ // A disabled day stays focusable through aria-disabled (spec:AST-085
+ // FR1); arrows still skip it and its click and hover are guarded.
// Initial roving tab-stop seed; useGridFocus owns it after mount.
tabIndex={isTabbableDay ? 0 : -1}
onClick={() => !state.effectivelyDisabled && onDayClick(date)}
diff --git a/packages/core/src/DateRangeInput/DateRangeInput.test.tsx b/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
index 7dd5f57567..99923de12f 100644
--- a/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
+++ b/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
@@ -1047,13 +1047,19 @@ describe('DateRangeInput range-span forwarding', () => {
fireEvent.click(getButton('Open calendar'));
// Before a start is picked, a far-off day is selectable.
- expect(dayButton('2026-01-20')).not.toBeDisabled();
+ expect(dayButton('2026-01-20')).not.toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
fireEvent.click(dayButton('2026-01-10') as HTMLButtonElement);
// A 7-day window spans start ± 6 days: Jan 16 is the edge, Jan 17 is out.
- expect(dayButton('2026-01-16')).not.toBeDisabled();
- expect(dayButton('2026-01-17')).toBeDisabled();
+ expect(dayButton('2026-01-16')).not.toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
+ expect(dayButton('2026-01-17')).toHaveAttribute('aria-disabled', 'true');
});
it('disables a preset whose range violates the span cap', () => {
diff --git a/packages/core/src/Pagination/Pagination.test.tsx b/packages/core/src/Pagination/Pagination.test.tsx
index e67075b2bf..1ade0a0e55 100644
--- a/packages/core/src/Pagination/Pagination.test.tsx
+++ b/packages/core/src/Pagination/Pagination.test.tsx
@@ -763,9 +763,13 @@ describe('Pagination', () => {
/>,
);
const dot = screen.getByRole('button', {name: 'Go to page 2'});
- expect(dot).toBeDisabled();
+ // spec:AST-085 FR1: the active dot keeps its tab stop, exposed as disabled.
+ expect(dot).not.toHaveAttribute('disabled');
+ expect(dot).toHaveAttribute('aria-disabled', 'true');
dot.focus();
+ expect(dot).toHaveFocus();
await user.keyboard('{ArrowRight}');
+ await user.keyboard('{Enter} ');
expect(onChange).not.toHaveBeenCalled();
});
});
diff --git a/packages/core/src/Pagination/Pagination.tsx b/packages/core/src/Pagination/Pagination.tsx
index b4691f6fd8..3e161fc2d8 100644
--- a/packages/core/src/Pagination/Pagination.tsx
+++ b/packages/core/src/Pagination/Pagination.tsx
@@ -706,7 +706,9 @@ export function Pagination({
// needs to focus the dot, which some browsers (Safari) skip for
// buttons, so focus it explicitly.
onClick={e => e.currentTarget.focus()}
- disabled={isDisabled}
+ // Disabled dots stay focusable (spec:AST-085 FR1); the page
+ // only follows focus while enabled (handleDotsFocus).
+ aria-disabled={isDisabled || undefined}
{...mergeProps(
themeProps('pagination-dot', {
active: isActive ? 'active' : null,
diff --git a/packages/core/src/TreeList/TreeList.test.tsx b/packages/core/src/TreeList/TreeList.test.tsx
index 0870597dc2..63b946a463 100644
--- a/packages/core/src/TreeList/TreeList.test.tsx
+++ b/packages/core/src/TreeList/TreeList.test.tsx
@@ -942,6 +942,34 @@ describe('TreeList', () => {
expect(screen.queryByText('File')).not.toBeInTheDocument();
});
+ it("exposes a disabled row's toggle and action as aria-disabled and keeps them inert", () => {
+ const onClick = vi.fn();
+ const {container} = render(
+ <TreeList
+ items={underRoot([
+ {id: 'run', label: 'Run', onClick, isDisabled: true},
+ {...folder, isDisabled: true},
+ ])}
+ />,
+ );
+ // spec:AST-085 FR1/FR2: no native disabled anywhere, and a click
+ // dispatched straight on the inner controls does nothing.
+ expect(container.querySelector('[disabled]')).toBeNull();
+ const toggle = container.querySelector<HTMLElement>(
+ '[data-tree-toggle][aria-disabled="true"]',
+ )!;
+ expect(toggle).not.toBeNull();
+ toggle.click();
+ fireEvent.keyDown(toggle, {key: 'Enter'});
+ expect(screen.queryByText('File')).not.toBeInTheDocument();
+ const action = Array.from(container.querySelectorAll('button')).find(
+ button => button.textContent?.includes('Run'),
+ )!;
+ expect(action).toHaveAttribute('aria-disabled', 'true');
+ action.click();
+ expect(onClick).not.toHaveBeenCalled();
+ });
+
it('leaves a role-based control in start or end content to itself', () => {
// Native and role-based controls alike keep their own activation,
// the same rule link rows get from the shared enlarged-surface hook.
diff --git a/packages/core/src/TreeList/TreeListItem.tsx b/packages/core/src/TreeList/TreeListItem.tsx
index 648daa226b..97edf6064d 100644
--- a/packages/core/src/TreeList/TreeListItem.tsx
+++ b/packages/core/src/TreeList/TreeListItem.tsx
@@ -38,6 +38,7 @@ import {TreeListBranches} from './TreeListBranches';
import type {TreeListDensity, TreeListVariant} from './TreeListTypes';
import {themeProps} from '../utils/themeProps';
import {useTranslator} from '../i18n';
+import {disabledInteractionProps} from '../utils/disabledInteraction';
// =============================================================================
// Styles
@@ -552,11 +553,13 @@ export function TreeListItem({
// Stable identity for TreeList's activateItem selector — do not
// remove without also updating TreeList.tsx.
data-tree-toggle=""
- disabled={isDisabled}
+ // Disabled stays focusable (spec:AST-085 FR1) but inert (FR2).
+ aria-disabled={isDisabled || undefined}
// Roving tabindex lives on the treeitem row; the chevron toggle is not
// a separate tab stop. Row-level Enter/Space forwards to this button.
tabIndex={-1}
onClick={handleToggle}
+ {...(isDisabled ? disabledInteractionProps() : null)}
{...mergeProps(
// Stable theme target for the expand/collapse control. `data-tree-toggle`
// stays as the functional activation hook; this adds a themeable
@@ -608,7 +611,8 @@ export function TreeListItem({
<button
type="button"
onClick={onClick}
- disabled={isDisabled}
+ aria-disabled={isDisabled || undefined}
+ {...(isDisabled ? disabledInteractionProps() : null)}
aria-labelledby={labelId}
aria-describedby={description != null ? descriptionId : undefined}
// Roving tabindex lives on the treeitem row; inner action is not a
diff --git a/packages/core/src/hooks/useGridFocus.ts b/packages/core/src/hooks/useGridFocus.ts
index ee8aa1e124..5332f55382 100644
--- a/packages/core/src/hooks/useGridFocus.ts
+++ b/packages/core/src/hooks/useGridFocus.ts
@@ -298,7 +298,22 @@ export function useGridFocus<T extends HTMLElement = HTMLElement>(
for (const el of targets) {
setTabIndex(el, el === tabbable ? 0 : -1);
}
- }, [getFocusTargets, setTabIndex]);
+ // A cell that stopped being focusable (an aria-disabled day, for example,
+ // which stays reachable by focus) can still hold the stop from earlier
+ // navigation; it never stays tabbable, so the grid keeps one Tab stop.
+ for (const cell of getCells()) {
+ const el = cellFocusable(cell) ? null : resolveFocusTarget(cell);
+ if (el != null) {
+ setTabIndex(el, -1);
+ }
+ }
+ }, [
+ getFocusTargets,
+ getCells,
+ cellFocusable,
+ resolveFocusTarget,
+ setTabIndex,
+ ]);
// Keep the tab stop valid across renders (cells added/removed, focusability
// toggled). Runs after every commit but only when roving tabindex is on.