Repository navigation
[Overflow] Add status reporting - #5661
Vincent Baaij (vnbaaij) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Switching between typed items and direct child content can leave a stale live-region overflow message because the previous count is captured using the new rendering mode; the capture needs correction and regression coverage in both directions.
1 open issue
What changed in this PR
Adds screen-reader status reporting to FluentOverflow to address the accessibility issue in #5525 by announcing overflow-count changes.
Changes:
- Adds a visually hidden, polite live region.
- Provides localizable messages for zero, one, or multiple overflow items, updating only when the count changes.
- Adds a test for live-region attributes and zero-to-one-to-zero message updates.
| File | Description |
|---|---|
tests/Core/Components/Overflow/FluentOverflowTests.razor |
Tests status attributes and message updates. |
src/Core/Localization/LanguageResource.resx |
Adds localizable overflow-count messages. |
src/Core/Components/Overflow/FluentOverflow.razor.css |
Visually hides the status region without hiding it from assistive technology. |
src/Core/Components/Overflow/FluentOverflow.razor.cs |
Updates status messages during parameter and overflow changes. |
src/Core/Components/Overflow/FluentOverflow.razor |
Renders the accessible live region. |
Review effort: Balanced
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.9%
Microsoft.FluentUI.AspNetCore.Components.Charts - 100%
|
| display: none; | ||
| } | ||
|
|
||
| [overflow-status] { |
There was a problem hiding this comment.
I think this is a good time to add these CSS codes, which are equivalent to those in Bootstrap: https://getbootstrap.com/docs/5.0/helpers/visually-hidden/
Probably in FluentUIStyles.ts.
// Bootstrap SCSS source for visually-hidden
.visually-hidden {
position: absolute !important;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
// Variant to make it visible again
.visually-hidden-focusable:not(:focus):not(:focus-within) {
position: absolute !important;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}| return; | ||
| } | ||
|
|
||
| _statusAnnouncement = overflowCount switch |
There was a problem hiding this comment.
The issue is not having three resource strings, but hardcoding the pluralization rules in the component. A 0 / 1 / other split works for English, but languages such as Russian and Arabic require different forms depending on the count.
Ideally, the component should pass the count to the localization layer, which selects the appropriate form using language-specific rules, such as ICU MessageFormat with CLDR plural categories. We could do that later.
A simpler alternative is a single resource with wording that avoids pluralization, such as Overflow item count: {0}.
| await InvokeAsync(StateHasChanged); | ||
| } | ||
|
|
||
| private void UpdateOverflowStatus(int previousOverflowCount) |
There was a problem hiding this comment.
Could we use a computed getter for StatusAnnouncement instead of maintaining _statusAnnouncement, and remove the overflowCount == previousOverflowCount check? Could you verify whether this preserves the expected behavior, including screen reader announcements? This would simplify the code.
The overflowCount == previousOverflowCount test prevents the same message from being reassigned. However, Blazor does not modify the DOM text if its value remains the same; therefore, this test is not necessary to prevent repeated notifications on every render.

Fix #5525
This PR adds a visually hidden live region to FluentOverflow with role="status", aria-live="polite", and aria-atomic="true". When the overflow count changes, the component updates its message to “1 item in overflow,” “N items in overflow,” or “No items in overflow” (all localizable). It checks for a count change before updating, so unchanged counts don’t trigger a new announcement.
The count is refreshed when parameters change and when overflow updates arrive. The added test verifies the live-region attributes and that changing the count from 0 to 1 and back updates its message.