Skip to content

Calendar accessibility fix#2529

Open
git-nandor wants to merge 2 commits intomasterfrom
calendar_accessibility_fix
Open

Calendar accessibility fix#2529
git-nandor wants to merge 2 commits intomasterfrom
calendar_accessibility_fix

Conversation

@git-nandor
Copy link
Copy Markdown
Contributor

@git-nandor git-nandor commented Apr 27, 2026

INSTUI-5009
INSTUI-5010
INSTUI-5014

Improve date picker calendar accessibility

Changes

  • Add aria-live="polite" aria-atomic="true" to the month/year header in
    Calendar v1 and v2. Previously the container was a <span> wrapping <div>
    children (invalid HTML), causing screen readers to lose track of the live
    region subtree and skip announcements on month navigation. Changed to <div>.

  • Add target month name to navigation button screen reader labels in Calendar
    v1 and v2. Default buttons now announce e.g. "Previous month, November 2023"
    instead of the generic "Previous month".

  • Extend renderPrevMonthButton/renderNextMonthButton prop type from Renderable
    to Renderable<{ targetMonthSrLabel: string }> in Calendar v1 and v2. When
    passed as a function, the render prop receives the pre-formatted target month
    label so consumers can build descriptive accessible names for custom buttons.

  • Update DateInput v2 to use function render props for navigation buttons,
    appending targetMonthSrLabel to the consumer-provided label string so the
    full announcement reads e.g. "Next month, January 2024".

  • Add aria-modal to Dialog when role="dialog" and shouldContainFocus is true,
    scoping the screen reader virtual cursor to the dialog content. Guarded by
    shouldContainFocus so non-modal Dialog usages (Tray without containment,
    DrawerTray during transitions, etc.) are unaffected.

    Test plan

  • Open a DateInput date picker with VoiceOver (macOS) or NVDA (Windows): verify the popover is announced as a dialog with its label (e.g. "Date picker, dialog")

  • The calendar heading displaying the year and month should use an h2

  • The last number in the yearPicker always fully visible

  • With the calendar open, press Tab past the last focusable element and Shift+Tab before the first: verify focus stays inside the picker and does not escape

  • Open a Modal, Tray, and Popover (non–date picker usage): verify aria-modal appears only when shouldContainFocus is true and does not appear on non-modal usages

  • Navigate to the next/previous month using the arrow buttons: verify the screen reader announces the new month and year (e.g. "January 2024") via the aria-live region without requiring the user to move focus

  • Check the previous and next month button accessible names: verify they include the target month (e.g. "Previous month, November 2023" / "Next month, January 2024") and not just the generic label

  • Pass a function to renderPrevMonthButton / renderNextMonthButton on Calendar v2: verify targetMonthSrLabel is received

  <Calendar
  renderPrevMonthButton={({ targetMonthSrLabel }) => (
    <IconButton
      size="small"
      renderIcon={<ChevronLeftInstUIIcon color="baseColor" />}
      screenReaderLabel={`Go to, ${targetMonthSrLabel}`}
    />
  )}
  renderNextMonthButton={({ targetMonthSrLabel }) => (
    <IconButton
      size="small"
      renderIcon={<ChevronRightInstUIIcon color="baseColor" />}
      screenReaderLabel={`Go to, ${targetMonthSrLabel}`}
    />
  )}
  selectedLabel="Selected"
 />

Co-Authored-By: 🤖 Claude

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2529/

Built to branch gh-pages at 2026-05-08 13:36 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@git-nandor git-nandor force-pushed the calendar_accessibility_fix branch 3 times, most recently from f821375 to 545f906 Compare April 27, 2026 18:47
@git-nandor git-nandor marked this pull request as ready for review April 28, 2026 07:10
@git-nandor git-nandor requested review from ToMESSKa and balzss April 28, 2026 07:32
@git-nandor git-nandor self-assigned this Apr 28, 2026
@git-nandor git-nandor force-pushed the calendar_accessibility_fix branch from 545f906 to 8d0db1b Compare April 28, 2026 13:45
Comment on lines 103 to 112
* prop to `small`, `withBorder` and `withBackground` to `false`, and setting
* `renderIcon` to [IconArrowOpenEnd](icons).
*/
renderNextMonthButton?: Renderable
renderNextMonthButton?: Renderable<{ targetMonthSrLabel: string }>
/**
* A button to render in the navigation header. The recommendation is to
* compose it with the [IconButton](Button) component by setting the `size`
* prop to `small`, `withBorder` and `withBackground` to `false`, and setting
* `renderIcon` to [IconArrowOpenStart](icons).
*/
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.

Can you please update the prop descriptions here too like in v2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Copy Markdown
Contributor

@ToMESSKa ToMESSKa left a comment

Choose a reason for hiding this comment

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

Really nice job. See my comment.

@git-nandor git-nandor force-pushed the calendar_accessibility_fix branch from 8d0db1b to 2ac9f89 Compare April 28, 2026 14:27
@git-nandor git-nandor requested a review from ToMESSKa April 28, 2026 14:28
@git-nandor git-nandor force-pushed the INSTUI-4989_DateInput2_days_missing_aria-selected branch 2 times, most recently from 60c5f40 to 3d35405 Compare May 7, 2026 13:16
Base automatically changed from INSTUI-4989_DateInput2_days_missing_aria-selected to master May 7, 2026 13:29
…DateInput v1 with DateInput v2 in DateTimeInput

BREAKING CHANGE: renderWeekdayLabels` prop removed

`calendarIcon` is a new required prop

INSTUI-4791
@git-nandor git-nandor force-pushed the calendar_accessibility_fix branch from 2ac9f89 to ba92f63 Compare May 7, 2026 14:35
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Visual regression report

⚠️ Changes detected.

Status Count
Unchanged 31
Changed 1
New 0
Removed 0

📊 View full report

Diff images (1)

calendar.png — 367 pixels differ

Baselines come from the visual-baselines branch. They refresh on every merge to master.

github-actions Bot pushed a commit that referenced this pull request May 7, 2026
Comment on lines +314 to +319
<div aria-live="polite" aria-atomic="true">
<h2 css={styles?.navigationLabel}>{visibleMonth.format('MMMM')}</h2>
{!withYearPicker ? (
<div>{visibleMonth.format('YYYY')}</div>
<h2 css={styles?.navigationLabel}>{visibleMonth.format('YYYY')}</h2>
) : null}
</span>
</div>
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.

Two sibling <h2>s split a single conceptual heading. Screen readers announce them as two separate headings ("December, heading level 2. 2023, heading level 2.") and both show up in heading navigation, instead of one combined "December 2023". aria-atomic doesn't merge them — the heading boundaries still apply.

Suggest collapsing into a single <h2> (which can also host the live-region attributes):

Suggested change
<div aria-live="polite" aria-atomic="true">
<h2 css={styles?.navigationLabel}>{visibleMonth.format('MMMM')}</h2>
{!withYearPicker ? (
<div>{visibleMonth.format('YYYY')}</div>
<h2 css={styles?.navigationLabel}>{visibleMonth.format('YYYY')}</h2>
) : null}
</span>
</div>
<h2
aria-live="polite"
aria-atomic="true"
css={styles?.navigationLabel}
>
<span>{visibleMonth.format('MMMM')}</span>
{!withYearPicker ? (
<span>{visibleMonth.format('YYYY')}</span>
) : null}
</h2>

If the existing two-line visual stacking matters, give the inner <span>s display: block in navigationLabel styles. One heading, one live region, one announcement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Modified

…eader, descriptive nav button labels with target month, aria-modal on focused dialogs
@git-nandor git-nandor force-pushed the calendar_accessibility_fix branch from ba92f63 to c184bc3 Compare May 8, 2026 13:32
@git-nandor git-nandor requested a review from balzss May 8, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants