Skip to content

fix(Calendar): the week-number corner cell is a named columnheader - #7509

Merged
cixzhang merged 2 commits into
mainfrom
fix/calendar-week-corner-role
Oct 14, 2026
Merged

cixzhang merged 2 commits into
mainfrom
fix/calendar-week-corner-role

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What changes for users

A screen-reader user reading a Calendar with hasWeekNumbers no longer meets a stray unnamed cell at the start of the weekday header row: the blank corner above the week-number column is now a columnheader named with the locale's own word for the week field ("week", "Woche", "週" — from CLDR, rendered as visually hidden text so the column stays blank), so every cell in the header row has a grid role and the row's column count matches the week rows below it.

Authority

Path (a): spec:AST-020 FR15 (current) plus the owner's 2026-10-13 APG adoption approval. APG Grid requires every cell in a row to be a gridcell, columnheader or rowheader; component:Calendar FR1 names the grid structure. A named columnheader is what the rowheader column it tops implies (the APG uses header roles for header cells; presentation would remove the cell from the grid's column model).

Shape

  • Calendar.tsx: the corner cell gets role="columnheader" and a <VisuallyHidden> child with plainDateWeekFieldName(locale) (text content, not aria-label, so axe's empty-table-header passes).
  • utils/plainDate.ts (an approved raw-Intl file under no-raw-intl-locale): plainDateWeekFieldName(locale) reads Intl.DisplayNames(locale, {type: 'dateTimeField'}).of('weekOfYear') — Chrome 106 / Safari 15.4 / Firefox 110, inside the Baseline − 2 tier — with the English CLDR value as the fallback. Not re-exported from the package. No new locale catalog key.
  • Calendar.test.tsx: "with week numbers, the header row's corner cell is a named columnheader, so every row child is a grid cell" — red on main, green here. plainDate.test.ts: plainDateWeekFieldName returns "week"/"Woche" and is never empty.
  • Record: FR1 names the week-number header cell; the FR1–FR5 verification row cites the new test. No gap sentence was on main for this, so none is deleted.
  • Changeset (patch).

Order

Queued after #7467 and #7478 (same component; independent files but the record's FR1–FR5 row is shared). When this merges after #7499, that binding's single-week-numbers known failure becomes an unexpected pass and is emptied there.

Writing rubric results

R1 narration: none; FR1 stays present tense.
R2 research: none in the record.
R3 evidence: the verification cell cites test titles, not this pull request.
R4 rejected alternatives: none added.
R5 change references: one #2715 inside a verbatim quoted test title already in the row, left as the test names itself.
R6 open questions: unchanged.

With hasWeekNumbers the header row's first cell had no role, so a grid row
carried a child that was neither gridcell, columnheader nor rowheader (APG
Grid; component:Calendar FR1). It is now a columnheader named 'Week'
(screen-reader only, translated), matching the weekday headers beside it
and the rowheader column it tops. FR1 states it; the verification row
cites the new test.
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 14, 2026 2:08am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@astracat-bot

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 14, 2026, 2:35 AM UTC

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Calendar (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1484 -
Complexity N/A Very High (139) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

44 of 448 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,150
TableRowExpansion Detail Panel neutral light 4,068

and 24 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is on hold until a maintainer provides or identifies the governing spec for its one unsettled addition, the new public catalog key @astryx.calendar.weekNumberHeader ("Week"): what must be settled is whether built-in screen-reader strings may enter the locale catalog as new keys, as the description already notes. Separately, the PR accessibility audit fails with two new empty-table-header findings on the new corner header, because axe does not count aria-label as header text; giving the header its translated name as visually hidden text content, or recording an approved baseline exception, should clear it while the column stays visually blank.

[Automated review]

Comment thread packages/core/src/Calendar/Calendar.tsx Outdated
// only so the column stays visually blank.
<div
role="columnheader"
aria-label={t('@astryx.calendar.weekNumberHeader')}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

axe's empty-table-header rule, which fails this PR's accessibility audit on the week-number stories, counts only text content inside a header, not aria-label. Keeping the column visually blank with the name as text content clears it:

<div
  role="columnheader"
  {...stylex.props(monthGridStyles.dayName, monthGridStyles.weekNumberHeader)}>
  <VisuallyHidden>{t('@astryx.calendar.weekNumberHeader')}</VisuallyHidden>
</div>

The new test's getByRole('columnheader', {name: 'Week'}) still passes with a name from content.

…n text; no new catalog key

plainDateWeekFieldName(locale) (plainDate.ts, an approved Intl file) reads
Intl.DisplayNames dateTimeField 'weekOfYear' — inside the Baseline − 2
tier — with the English CLDR value as the fallback. The header renders it
through VisuallyHidden, so axe's empty-table-header passes and the column
stays blank. The @astryx.calendar.weekNumberHeader key is gone.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 172e8b7

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No changes are needed: the week-number corner is now a columnheader whose CLDR name is visually hidden, which matches the adopted Grid pattern while the column stays blank. The new test fails without the fix and passes with it, the accessibility audit is clean on both week-number stories, and the calendar renders pixel-identically before and after. One optional extra: a Calendar.test.tsx case that makes Intl.DisplayNames throw would cover the English fallback, which neither new test reaches.

[Automated review]

expect(stray).toHaveLength(0);
// Named from CLDR ("week" in en-US), as visually hidden text.
expect(
within(grid).getByRole('columnheader', {name: 'week'}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional hardening: neither new test reaches the English fallback in plainDateWeekFieldName, because ICU names zxx “week” through CLDR root. A case like this one covers it, passes at head, and stays inside the no-raw-intl-locale boundary because this file is an approved test oracle:

it('names the week-number corner "week" when the engine cannot name the field', () => {
  const real = Intl.DisplayNames;
  Object.defineProperty(Intl, 'DisplayNames', {
    value: class {
      constructor() {
        throw new RangeError('unsupported type');
      }
    },
    configurable: true,
    writable: true,
  });
  try {
    render(
      <InternationalizationProvider locale="de-DE">
        <Calendar focusDate="2026-01-01" hasWeekNumbers />
      </InternationalizationProvider>,
    );
    expect(
      within(screen.getByRole('grid')).getByRole('columnheader', {name: 'week'}),
    ).toBeInTheDocument();
  } finally {
    Object.defineProperty(Intl, 'DisplayNames', {value: real, configurable: true, writable: true});
  }
});

@cixzhang
cixzhang merged commit 69d7345 into main Oct 14, 2026
56 checks passed
cixzhang added a commit that referenced this pull request Oct 14, 2026
cixzhang added a commit that referenced this pull request Oct 14, 2026
…ts known-failure row goes; the ledger is empty
cixzhang added a commit that referenced this pull request Oct 14, 2026
## What this proves

`component:Calendar` AR1 (the Grid adoption recorded in `component:Calendar`, now on `main`, under `spec:AST-020` FR15) has an executable contract and a binding. A keyboard or screen-reader user in a Calendar month gets: a named grid whose rows are rows of gridcells (with a column-header row), one Tab stop per grid, selected days exposed as selected (and the grid marked multi-selectable in range mode), the arrows moving one cell at a time in reading order, Home/End to the ends of the week row, and Enter picking the focused day.

Test-only: no runtime, docs, or Changeset. Enforcement follows `spec:AST-020` FR9: the APG Grid's required parts are `required`; Enter's default action (author-determined in APG, defined by the record) is `advisory` until `component:Calendar` is current.

## Expectations (AST-020 FR13)

| Expectation | Sources | Layer | Enforcement |
| --- | --- | --- | --- |
| `grid.container.role-and-name` | WCAG 4.1.2, APG Grid, APG Grid | accessibility-tree | required |
| `grid.structure.rows-and-cells` | WCAG 1.3.1, APG Grid | dom | required |
| `grid.focus.single-tab-stop` | WCAG 2.1.1, WCAG 2.4.3, APG Grid | dom | required |
| `grid.selection.exposed` | WCAG 4.1.2, APG Grid, WAI-ARIA 1.2 | dom | required |
| `grid.keys.arrows` | WCAG 2.1.1, APG Grid | real-browser | required |
| `grid.keys.home-end` | WCAG 2.1.1, APG Grid | real-browser | required |
| `grid.keys.enter-activates` | WCAG 2.1.1, `component:Calendar` AR1 | real-browser | advisory |

Exemptions: `1.1.1-non-text-content` → the binding component and caller content; `1.3.1-info-and-relationships` → the binding component (remainder only); `1.3.2-meaningful-sequence` → the binding component; `1.3.5-identify-input-purpose` → not applicable; `1.4.1-use-of-color` → the binding component and theme; `1.4.3-contrast-minimum` → the binding component and theme; `1.4.11-non-text-contrast` → the binding component and theme; `2.1.1-keyboard` → the binding component and composing page (remainder only); `2.1.2-no-keyboard-trap` → the binding component and composing page; `2.4.2-page-titled` → the page; `2.4.3-focus-order` → the composing page (remainder only); `2.4.4-link-purpose` → not applicable; `2.4.6-headings-and-labels` → the binding component and caller content (remainder only); `2.4.7-focus-visible` → the binding component and theme; `2.4.11-focus-not-obscured` → the composing page; `2.5.2-pointer-cancellation` → the binding component; `2.5.3-label-in-name` → the binding component; `2.5.8-target-size` → the binding component and theme; `3.1.1-language-of-page` → the page; `3.2.2-on-input` → the caller and composing page; `3.2.4-consistent-identification` → the composing page; `3.3.1-error-identification` → the binding component; `3.3.2-labels-or-instructions` → the binding component and caller content; `4.1.2-name-role-value` → the binding component (remainder only); `4.1.3-status-messages` → the binding component and the assistive-technology verification record, spec:AST-009; `apg-interaction` → the binding component's record (remainder only); `forced-colors` → the binding component and theme; `reduced-motion` → the binding component and theme; `at-facing-strings` → the binding component

## Known failures

None: the week-numbers corner-cell gap this binding first recorded was fixed on `main` by #7509 before this binding merged, so its row was emptied; every state passes every applicable expectation in jsdom and Chromium.

## Shape

- `internal/a11y-spec/src/patterns/grid.ts` — `GRID_PATTERN`, 7 expectations whose sources say what their pages say: APG Grid for roles, rows, naming, selection and the data-grid Tab/arrow/Home/End text (verified against the published pattern on 2026-10-13); WAI-ARIA 1.2 for `aria-multiselectable`; `component:Calendar` AR1 (pinned) for Enter/Space picking the focused day, which the APG leaves author-determined; every other checklist dimension exempted to a named owner with a verification method. Structure counts use the new `Subject.descendantCount(selector)`.
- `grid.fixtures.ts` — a 3×3 HTML grid whose `<script>` implements the roving-tabindex data-grid model; every expectation has at least one violating twin (`GRID_MUTATIONS`, 10 mutations).
- `grid.jsdom.test.ts` (24 cases) and `grid.chromium.spec.ts`.
- `internal/a11y-spec/src/harness.ts` + `harness/{jsdom,chromium}.ts` — `Subject.descendantCount`; (`Home`/`End` keys came in with the Slider contract.)
- `packages/core/src/Calendar/__tests__/Calendar.a11y.{states,renders,test}.tsx` and `Calendar.a11y.chromium.spec.ts` — four states, each starting on January 14, 2026 with a full in-month neighbourhood: single with January 20 selected; the same under RTL (ArrowLeft moves to the next day); single with `hasWeekNumbers` (its corner-cell header, fixed by #7509); a two-month range (January 20–22) with the first grid as the subject (Enter starts a new range there, so the activation row does not apply). Related subjects: `start`, `startCell`, `next`, `previous`, `below`, `above`, `rowStart`, `rowEnd`.
- `apps/storybook/stories/CalendarGridA11y.stories.tsx` — one `no-visual` story per state through `renderCalendarState`.
- `.github/workflows/ci.yml` — "Run Grid accessibility contract" step; scope through `pr-scope-touches.sh` from the base; runs when Calendar, `useGridFocus`, the harness, the stories, or the contract change.
- README row and index export.

## Source lines behind the binding facts

`role="grid"` + `aria-label={monthLabel}` + `aria-multiselectable` in range mode (Calendar.tsx L888–892); header `role="row"` of `columnheader`s (L901–913); week `role="row"`s of `role="gridcell"`s (L927, L1112); roving `tabIndex` via `useGridFocus` with `hasRovingTabIndex` (L802–806); arrows/Home/End in `useGridFocus.ts`; Enter picks the focused day (`handleDayClick`, L432–448).

## Ownership exclusions

`CALENDAR_EXCLUSIONS`: disabled-day arrow skipping (an arrow that meets a day disabled by bounds or a constraint skips it and continues — `component:Calendar` AR1's rule beyond the APG one-cell step; `Calendar.test.tsx` proves it, so the binding's states stay free of disabled days); month-edge crossing (`component:Calendar` FR5 — the APG grid stops at the edge, the record defines the crossing; every state starts mid-month); pointer selection (`Calendar.test.tsx`) and Page keys (owned by `Calendar.test.tsx`'s five Page-key cases from #7467, now on `main`). DateInput's month panes bind in their own change.

## Moved and retained local tests (AST-021 FR6, FR14)

Moved into the binding: `Calendar.test.tsx` "sets aria-multiselectable=\"true\" on the grid in range mode" (→ `grid.selection.exposed` on the `range-two-months` state, same DOM layer). Retained: "sets aria-multiselectable on both grids in a two-month range view" (the second grid, which the binding does not subject) and "does not set aria-multiselectable in single mode" (cited by `component:Calendar` AR1); "has accessible grid structure" and "renders a valid APG grid: one grid, header row of columnheaders inside it, week rows of gridcells" (cited by AR1/FR1–FR5 — removal blocker: the record is `draft` and cites them; they come out with the record pass that makes it current); "with week numbers, the header row's corner cell is a named columnheader, so every row child is a grid cell" (the stray-child check that red-armed #7509; cited by FR1–FR5 — same blocker).

## Evidence

- Vitest Calendar directory green (incl. 8 binding cases); pattern jsdom self-test 24/24; a11y-spec package tests green; tsc (core, a11y-spec, storybook), eslint, Prettier, use-client, visual-workflow-owner clean.
- Real Chromium: the CI step on this PR runs the fixture self-test (conforming pass, every mutation fails) and the four binding states, with no known failures.
@github-actions
github-actions Bot deleted the fix/calendar-week-corner-role branch October 14, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — 172e8b7b Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant