Skip to content

refactor: use ariaNotify over @primer/live-region-element - #8641

Draft
joshblack wants to merge 13 commits into
mainfrom
refactor/use-aria-notify
Draft

joshblack wants to merge 13 commits into
mainfrom
refactor/use-aria-notify

Conversation

@joshblack

@joshblack joshblack commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Update our usage of @primer/live-region-element in favor of ariaNotify, using @github/arianotify-polyfill as a fallback for older browsers.

ariaNotify is baseline 2026 and will be the defacto way to make screen reader announcements moving forward. We recommend using it directly in components along with our existing helpers that help out with blocks that would like to do role="alert", role="status", etc

Changelog

New

  • Add polyfill for ariaNotify and global type defs

Changed

  • Remove @primer/live-region-element from packages/react
  • Update Announce, AriaAlert, AriaStatus to use ariaNotify
  • Update downstream components, tests, and stories as-needed

Removed

Rollout strategy

  • No changes needed in github/github-ui

Testing & Reviewing

@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a288309

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions
github-actions Bot requested a deployment to storybook-preview-8641 October 29, 2026 21:45 Abandoned
@primer

primer Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

@github-actions
github-actions Bot requested a deployment to storybook-preview-8641 October 29, 2026 21:51 Abandoned
@primer

primer Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

@joshblack
joshblack requested a balanced review from Copilot October 29, 2026 21:58
@github-actions
github-actions Bot requested a deployment to storybook-preview-8641 October 29, 2026 22:00 Abandoned

Copilot AI 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.

🟡 Changes recommended

Hook-only bundles can omit the required polyfill and crash announcements on browsers without native support, while hidden-text handling and the required minor-release changeset also remain unresolved.

3 open issues
What changed in this PR

Migrates Primer React’s screen reader announcements from @primer/live-region-element to ariaNotify, with a polyfill for older browsers.

Changes:

  • Adds a shared announcement hook with local debounce and cancellation.
  • Updates components and stories to use the new announcement API.
  • Expands tests for timing, cancellation, hidden content, and StrictMode behavior.
File Description
packages/​react/​src/​TreeView/​TreeView.test.tsx Checks loading announcements through ariaNotify.
packages/​react/​src/​TextInput/​TextInput.test.tsx Verifies counter announcement timing.
packages/​react/​src/​Textarea/​Textarea.test.tsx Verifies counter announcement timing.
packages/​react/​src/​SelectPanel/​SelectPanel.tsx Migrates announcements and cancels stale loading messages.
packages/​react/​src/​SelectPanel/​SelectPanel.test.tsx Adds announcement cancellation and isolation coverage.
packages/​react/​src/​polyfills/​ariaNotify.ts Imports the fallback and declares API types.
packages/​react/​src/​live-region/​useAnnounce.ts Adds per-instance announcement scheduling and cancellation.
packages/​react/​src/​live-region/​index.ts Exports the announcement hook internally.
packages/​react/​src/​live-region/​Announce.tsx Uses element-scoped notifications and rendered text.
packages/​react/​src/​live-region/​__tests__/​test-helpers.ts Removes the obsolete live-region helper.
packages/​react/​src/​live-region/​__tests__/​AriaStatus.test.tsx Checks status notifications at the API boundary.
packages/​react/​src/​live-region/​__tests__/​AriaAlert.test.tsx Checks alert notifications at the API boundary.
packages/​react/​src/​live-region/​__tests__/​Announce.test.tsx Covers delays, cancellation, visibility, and StrictMode.
packages/​react/​src/​FilteredActionList/​useAnnouncements.tsx Migrates list announcements and manages deferred work.
packages/​react/​src/​FilteredActionList/​useAnnouncements.test.tsx Tests notification content and loading cancellation.
packages/​react/​src/​experimental/​SelectPanel2/​__tests__/​SelectPanelLoading.test.tsx Checks loading messages through ariaNotify.
packages/​react/​src/​Button/​Button.features.stories.tsx Updates counter announcement examples.
packages/​react/​src/​BranchName/​BranchName.features.stories.tsx Updates the copy confirmation announcement.
packages/​react/​src/​Autocomplete/​AutocompleteMenu.tsx Uses local scheduling for empty-result announcements.
packages/​react/​package.json Replaces the dependency and preserves polyfill side effects.
package-lock.json Records the dependency replacement.
.changeset/​select-panel-announcements.md Documents stale SelectPanel announcement fixes.
.agents/​skills/​live-regions/​SKILL.md Documents announcement APIs and testing guidance.

Review effort: Balanced

Comment thread packages/react/src/live-region/useAnnounce.ts
Comment on lines +2 to +5
'@primer/react': patch
---

SelectPanel: Prevent stale loading and list announcements after results arrive or the panel closes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot add a separate changeset for the minor bump that you're describing

Comment thread packages/react/src/live-region/Announce.tsx Outdated

Copilot AI commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

@joshblack I've opened a new pull request, #8642, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@primer

primer Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

This branch was successfully deployed

2 active deployments
storybook-preview-8641 — a288309c Deployed Oct 30, 2026 by github-actions[bot]
github-pages — a288309c Deployed Oct 30, 2026 by joshblack via deploy-preview #33981
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants