Skip to content

fix: Only use Title as aria-label on buttons without visible text - #5591

Merged
Vincent Baaij (vnbaaij) merged 2 commits into
microsoft:devfrom
p6laris:fix/button-title-aria-label
Nov 4, 2026
Merged

Vincent Baaij (vnbaaij) merged 2 commits into
microsoft:devfrom
p6laris:fix/button-title-aria-label

Conversation

@p6laris

@p6laris p6laris commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

📖 Description

Buttons with text and a Title were getting the title as their aria-label, so the accessible name lost the visible text (WCAG 2.5.3). Now Title only becomes the aria-label when there's no Label or ChildContent, the same check icon-only already uses. This covers FluentButton, FluentAnchorButton, FluentCompoundButton, FluentMenuButton and FluentToggleButton. FluentSplitButton was already fine since its aria-label is on the arrow-only toggle.

🎫 Issues

Fixes #5590

👩‍💻 Reviewer Notes

Two snapshots lose their aria-label (FluentButton_Title and FluentCompoundButton_Title). That's intended.

📑 Test Plan

I added two tests per component: with text there's no aria-label, and icon-only keeps Title as its aria-label. The text tests and the two snapshots fail without the fix. All of tests/Core passes (5207). I didn't run the demo or try a screen reader.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Issue discussion declaration

Discuss changes before implementing them to confirm that the problem and proposed approach fit the project. See Discuss before implementing for the process and exceptions.

  • I have discussed this change in an issue and received maintainer agreement before implementation, or a documented exception applies.

AI contribution declaration

AI assistance is allowed; fully AI-generated or autonomous pull requests without meaningful human review are not accepted. See the AI contribution policy.

  • I have read and followed the AI contribution policy.
  • I have personally reviewed and understood all changes, tested them, and take responsibility for this contribution.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

MCP Server

  • I have added or updated MCP Server tools/prompts/resources
  • I have added Unit Tests for my MCP Server changes

⏭ Next Steps

None.

Title was always copied into aria-label, so a button with text lost its visible text as accessible name (WCAG 2.5.3, Label in Name). Now Title becomes the aria-label only when the button has no Label or ChildContent.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 07:12

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

The conditional Title handling removes explanatory tooltips and can leave icon-only buttons and links with custom SVG content without an accessible name.

2 open issues
What changed in this PR

This PR addresses #5590 by preventing button titles from overriding visible text in accessible names across five Fluent UI Blazor components.

Changes:

  • Conditionally emit Title as aria-label when no Label or ChildContent is supplied.
  • Add text-content and icon-only regression tests for each affected component.
  • Update two snapshots to omit the accessible-name override.
File Description
tests/​Core/​Components/​Button/​FluentToggleButtonTests.razor Adds title accessibility tests.
tests/​Core/​Components/​Button/​FluentMenuButtonTests.razor Adds title accessibility tests.
tests/​Core/​Components/​Button/​FluentCompoundButtonTests.razor Adds title accessibility tests.
tests/​Core/​Components/​Button/​FluentCompoundButtonTests.FluentCompoundButton_Title.verified.razor.html Removes the expected aria-label.
tests/​Core/​Components/​Button/​FluentButtonTests.razor Tests accessible naming and tooltip retention.
tests/​Core/​Components/​Button/​FluentButtonTests.FluentButton_Title.verified.razor.html Removes aria-label while retaining title.
tests/​Core/​Components/​Button/​FluentAnchorButtonTests.razor Adds title accessibility tests.
src/​Core/​Components/​Button/​FluentToggleButton.razor Makes the title-derived label conditional.
src/​Core/​Components/​Button/​FluentMenuButton.razor Makes the title-derived label conditional.
src/​Core/​Components/​Button/​FluentCompoundButton.razor Checks content before emitting the title-derived label.
src/​Core/​Components/​Button/​FluentButton.razor Makes the title-derived label conditional.
src/​Core/​Components/​Button/​FluentAnchorButton.razor Makes the title-derived label conditional.

Review effort: Balanced

@vnbaaij
Vincent Baaij (vnbaaij) merged commit e5c0ddc into microsoft:dev Nov 4, 2026
4 of 5 checks passed
This was referenced Nov 16, 2026
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.

fix: Title becomes the accessible name in FluentButton

4 participants