Skip to content

[Select] Fix aria-label will be ignored - #5356

Merged
Vincent Baaij (vnbaaij) merged 2 commits into
microsoft:devfrom
MarvinKlein1508:aria-label-fluentselect
Sep 28, 2026
Merged

Vincent Baaij (vnbaaij) merged 2 commits into
microsoft:devfrom
MarvinKlein1508:aria-label-fluentselect

Conversation

@MarvinKlein1508

Copy link
Copy Markdown
Collaborator

Pull Request

📖 Description

This PR adds a check for an existing aria-label attribute to FluentSelect.ts. If an attribute is provided it favoured over everything else. Previously FluentSelect has used this flow to determine the aria-label:

  • If the parameter Label was set it was used as the value for aria-label
  • If the parameter Label was not set and the parameter Placeholder was set then the Placeholder was being used as the aria-label
  • If both parameters were not set an hardcoded string Select an option was used as the aria-label

The new flow is now:

  • If the parameter AriaLabel is set then this is being used as the aria-label
  • If the parameter AriaLabel is not set and the parameter Label is set then it will be used as the value for aria-label
  • If the parameters AriaLabel and Label are not set and the parameter Placeholder is set then the Placeholder parameter is being used as the aria-label
  • If all three parameters are not set an hardcoded string Select an option is used as the aria-label

🎫 Issues

Fix #5352

✅ 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.

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

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.

Copilot review overview

🟡 Changes recommended

The default label remains untranslated, and the test does not verify the shadow-DOM control path.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Updates FluentSelect accessibility labeling so an explicit aria-label takes precedence.

Changes:

  • Prioritizes host aria-label values.
  • Adds AriaLabel test coverage.
File Summary
tests/​Core/​Components/​List/​FluentSelectTests.razor Adds explicit AriaLabel coverage.
src/​Core.Scripts/​src/​Components/​List/​FluentSelect.ts Resolves explicit accessible labels.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vnbaaij Vincent Baaij (vnbaaij) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The issue reports that the script returns an untranslatable string 'Select an option' which is indeed the case (line 83 in FluentSelect.ts). Besides your changes (which are good), there should to be a way to translate that string. Is that now possible by supplying an AriaLable parameter to the component?

@MarvinKlein1508

Copy link
Copy Markdown
Collaborator Author

The issue reports that the script returns an untranslatable string 'Select an option' which is indeed the case

Not sure if we want to change this here. I actually don't know how I should use the localizer in the ts files.

there should to be a way to translate that string. Is that now possible by supplying an AriaLable parameter to the component?

Yes you can pass AriaLabel to the component. The method only falls back to the untraslated string if neither of those parameter are defined: AriaLabel, Label, Placeholder (in exactly this order).

The component had the AriaLabel parameter previously but the value from it wasn't considered in the underlying typescript file

@vnbaaij

Copy link
Copy Markdown
Collaborator

Not sure if we want to change this here. I actually don't know how I should use the localizer in the ts files.

No, we don't want to do localizer in the ts files.

Yes you can pass AriaLabel to the component. The method only falls back to the untraslated string if neither of those parameter are defined: AriaLabel, Label, Placeholder (in exactly this order).

The component had the AriaLabel parameter previously but the value from it wasn't considered in the underlying typescript file

That is exactly what I meant. It should be possible to provide a translated value and we have that now.

@vnbaaij
Vincent Baaij (vnbaaij) merged commit d55257d into microsoft:dev Sep 28, 2026
4 of 5 checks passed
@MarvinKlein1508
Marvin Klein (MarvinKlein1508) deleted the aria-label-fluentselect branch September 28, 2026 08:45
This was referenced Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FluentSelect: hard-coded English accessible name "Select an option", AriaLabel not applied to the combobox

3 participants