Skip to content

fix: Improve live region behavior for short-lived content updates#4310

Open
avinashbot wants to merge 4 commits intomainfrom
live-region-content-update
Open

fix: Improve live region behavior for short-lived content updates#4310
avinashbot wants to merge 4 commits intomainfrom
live-region-content-update

Conversation

@avinashbot
Copy link
Member

@avinashbot avinashbot commented Feb 27, 2026

Description

One of the common use-cases for the live region component is for announcing content loading/refreshing changes. Something like "Reloading things" -> "Last updated: " (see loading and refreshing). However, the live region deduplicates and throttles updates, which means that this information may not be properly conveyed under certain circumstances.

  • (Refresh button clicked)
  • Annoucement: Loading issues (suppressed if loading takes < 2 seconds)
  • Announcement: Last updated: December 21, 2023, 14:29 (announced)
  • (Refresh button clicked again)
  • Annoucement: Loading issues (suppressed if loading takes < 2 seconds)
  • Announcement: Last updated: December 21, 2023, 14:29 (suppressed since the text is the same as the last announcement, this is bad)

So I updated the controller to force an announcement even if the text is the same if there was an update in between (like the text Loading issues). Also reduced the delay to 1 second to make the announcements snappier (but I don't feel comfortable going any lower than that in case the live region is used in conjuction with user input)

Related links, issue #, if available: AWSUI-61749, AWSUI-61345

How has this been tested?

Updated unit tests.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.43%. Comparing base (80272d6) to head (5f1bf04).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4310   +/-   ##
=======================================
  Coverage   97.43%   97.43%           
=======================================
  Files         896      897    +1     
  Lines       26298    26347   +49     
  Branches     9496     9519   +23     
=======================================
+ Hits        25623    25672   +49     
  Misses        632      632           
  Partials       43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gethinwebster
Copy link
Member

Added a demo page that I was playing around with locally. It seems like the fix causes the "Loading" message to take priority over "Loading complete" (or at least something prevents "Loading complete" from being announced, which I think would be optimal here)

@avinashbot
Copy link
Member Author

Thanks! Used that as the test-case to fix up the logic. There are still some conflicts because when loading completes, you now have two independent announcements fighting to be announced, so I had to comment out one of them in the test page. I think we'll have to ask for the same changes in the code where this was found.

@avinashbot avinashbot marked this pull request as ready for review March 4, 2026 20:38
@avinashbot avinashbot requested a review from a team as a code owner March 4, 2026 20:38
@avinashbot avinashbot requested review from amanabiy and removed request for a team March 4, 2026 20:38
}
}

announce({ message, forceReannounce = false }: { message?: string; delay?: number; forceReannounce?: boolean }) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Realized while refactoring that the delay parameter here actually does nothing. I removed it from src/live-region/internal.tsx (and moved it to the class constructor).

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.

2 participants