Skip to content

Conversation

@mperrotti
Copy link
Contributor

Closes https://github.com/github/primer/issues/4892

Changelog

New

Changed

  • Replaces 'aria-live' usage with newer helpers

Removed

  • Internal LiveRegion component

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@mperrotti mperrotti requested a review from a team as a code owner November 21, 2025 22:12
@changeset-bot
Copy link

changeset-bot bot commented Nov 21, 2025

🦋 Changeset detected

Latest commit: 7566471

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

@mperrotti mperrotti requested a review from joshblack November 21, 2025 22:12
@github-actions
Copy link
Contributor

👋 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. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 21, 2025
Copilot finished reviewing on behalf of mperrotti November 21, 2025 22:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the accessibility announcement system by replacing direct aria-live attributes and the internal LiveRegion component with the newer AriaStatus helper from the live-region module. This provides a more maintainable and React-friendly approach to screen reader announcements across the design system.

Key Changes

  • Removed the internal LiveRegion component entirely and all its dependencies
  • Migrated all aria-live attribute usage to the AriaStatus component from the live-region module
  • Updated tests to use the getLiveRegion() test helper for verifying announcements

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react/src/internal/components/LiveRegion.tsx Removed the entire internal LiveRegion component implementation
packages/react/src/experimental/SelectPanel2/SelectPanel.tsx Replaced aria-live attributes with AriaStatus component for status messages
packages/react/src/TreeView/TreeView.tsx Replaced VisuallyHidden with aria-live attributes with AriaStatus component
packages/react/src/TreeView/TreeView.test.tsx Updated tests to use getLiveRegion() helper and improved test robustness by using getByRole
packages/react/src/Skeleton/Skeleton.examples.stories.tsx Wrapped loading announcements in AriaStatus component
packages/react/src/DataTable/Pagination.tsx Removed LiveRegion/Message usage and replaced with AriaStatus for pagination announcements
.changeset/easy-suits-mate.md Added changeset documenting the changes as a patch release

<VisuallyHidden role="status" aria-live="polite" aria-atomic="true">
{ariaLiveMessage}
<VisuallyHidden>
{/* Message fail without passing a `key` */}
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The comment has a grammar issue. It should be "Messages fail" (plural) or "Message fails" (singular with correct verb form) instead of "Message fail".

Suggested change
{/* Message fail without passing a `key` */}
{/* Message fails without passing a `key` */}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, we're getting rid of the key. Thanks though.

Comment on lines 1396 to 1398
// Set up live region for this test
const liveRegionEl = document.createElement('live-region')
document.body.appendChild(liveRegionEl)
Copy link
Member

Choose a reason for hiding this comment

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

The live region utilities should be doing this automatically, let me know if not 👀

I think test-wise we just have to have a clean up for them, e.g.

afterEach(() => {
  const liveRegion = document.querySelector('live-region');
  document.body.removeChild(liveRegion);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I thought too, but they weren't.

Copy link
Member

Choose a reason for hiding this comment

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

@mperrotti if I remove these lines from the test it still seems to pass, are you seeing that too or no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, that's odd. The failures may have been caused by something else I changed. Will remove.

<VisuallyHidden role="status" aria-live="polite" aria-atomic="true">
{ariaLiveMessage}
<VisuallyHidden>
{/* Message fail without passing a `key` */}
Copy link
Member

Choose a reason for hiding this comment

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

Ooo what issue were you running into without key? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just wasn't picking up the content. Here's the test failure when I don't pass a key:

 FAIL   @primer/react (chromium)  src/TreeView/TreeView.test.tsx > Asynchronous loading > updates aria live region when loading is done
AssertionError: expected '' to be 'Parent content loading' // Object.is equality

- Expected
+ Received

- Parent content loading

 ❯ toBe src/TreeView/TreeView.test.tsx:1442:44
    1440|     fireEvent.click(doneButton)
    1441| 
    1442|     expect(liveRegion.getMessage('polite')).toBe('Parent content loading')
       |                                            ^
    1443| 
    1444|     // Click done button to mimic the completion of async loading

Copy link
Member

Choose a reason for hiding this comment

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

@mperrotti it seems like the test is complaining about updates not being wrapped in act() when debugging locally, are you seeing that as well? When updating to the following it seemed to work without key:

    // Click load button to mimic async loading
    await act(async () => {
      await user.click(doneButton)
    })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh ok I see! Will update. Thank you!

Co-authored-by: Josh Black <joshblack@github.com>
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

🥳

@mperrotti mperrotti added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit 534ca11 Dec 2, 2025
49 checks passed
@mperrotti mperrotti deleted the mp/update-aria-live-usage branch December 2, 2025 17:10
@primer primer bot mentioned this pull request Dec 2, 2025
@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/8147

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Dec 5, 2025
@primer-integration
Copy link

🔴 ci completed with status failure.

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh labels Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: failing Changes in this PR cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants