Skip to content

Inputs: Align ARIA invalid state with computed validation errors#12972

Merged
danielchalmers merged 2 commits intoMudBlazor:devfrom
danielchalmers:quiet-silkworm
Apr 7, 2026
Merged

Inputs: Align ARIA invalid state with computed validation errors#12972
danielchalmers merged 2 commits intoMudBlazor:devfrom
danielchalmers:quiet-silkworm

Conversation

@danielchalmers
Copy link
Copy Markdown
Member

@danielchalmers danielchalmers commented Apr 4, 2026

Some inputs could render an error while the focused input still exposed itself as valid because the ARIA invalid state followed the raw Error parameter, not the full computed error state. As a result, conversion and validation failures could be visible on screen but not communicated correctly to assistive technology.

If it shows a field as invalid, the real input element should also report it as invalid. Anything else creates inconsistent behavior between visual validation and screen reader output.

Checklist:

  • I've read the contribution guidelines
  • My code follows the style of this project
  • I've added or updated relevant unit tests

## Why

MudBlazor already renders validation and conversion errors visually, but the accessibility state exposed on the actual focus target was narrower than the state shown to the user.

In practice, that meant a control could be visibly invalid while still reporting itself as valid to assistive technology. The clearest case was conversion/parsing failures: the error text appeared, but the focused input could still expose `aria-invalid="false"` because the rendered ARIA state followed the raw `Error` parameter instead of the computed error state.

That mismatch is more than a polish issue:

- It gives screen reader users different feedback than sighted users.
- It makes validation semantics inconsistent across wrapper components.
- It weakens trust in the component model, because the outer control and the inner focus target can disagree about whether the field is invalid.

## Reasoning

The accessibility contract should follow the same state model that drives the visible error UI.

If MudBlazor considers a field invalid because of validation or conversion, the element that actually receives focus should expose that same invalid state. Otherwise the framework is effectively telling assistive technology that nothing is wrong while showing an error on screen.

This is especially important in wrapper-based components such as text fields, numeric fields, selects, autocomplete, and pickers, where the user interacts with an inner input but the error state often originates higher in the component stack. If that state is not carried through consistently, the rendered ARIA semantics become unreliable.

## Scope

This PR is intentionally limited to the highest-confidence part of the problem: making invalid-state semantics follow computed errors consistently.

It does not try to solve every helper/error relationship in one pass. More advanced follow-up work like broader error-message linkage can build on this baseline, but the baseline itself needs to be correct first.
@danielchalmers danielchalmers requested a review from versile2 as a code owner April 4, 2026 21:03
@mudbot mudbot bot changed the title Align input ARIA invalid state with computed validation errors Inputs: Align input ARIA invalid state with computed validation errors Apr 4, 2026
@mudbot mudbot bot added accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) bug Unexpected behavior or functionality not working as intended labels Apr 4, 2026
@danielchalmers danielchalmers changed the title Inputs: Align input ARIA invalid state with computed validation errors Inputs: Align ARIA invalid state with computed validation errors Apr 4, 2026
@danielchalmers danielchalmers merged commit 97aaa75 into MudBlazor:dev Apr 7, 2026
11 checks passed
@danielchalmers danielchalmers deleted the quiet-silkworm branch April 7, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Accessibility concerns (ARIA, keyboard, focus, screen readers, contrast) bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants