Skip to content

Fix language dropdown arrow-key behavior and duplicate zh-CN entry in dashboard settings#16094

Merged
JamesNK merged 2 commits intomicrosoft:mainfrom
adamint:dev/adamint/fix-language-dropdown
Apr 13, 2026
Merged

Fix language dropdown arrow-key behavior and duplicate zh-CN entry in dashboard settings#16094
JamesNK merged 2 commits intomicrosoft:mainfrom
adamint:dev/adamint/fix-language-dropdown

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Apr 12, 2026

Description

Fixes the language dropdown in the dashboard settings and zh-CN locale handling.

Changes

  • Fix dropdown arrow-key behavior: Replace Immediate="true" with ChangeOnEnterOnly="true" on the language FluentSelect so that arrow-key navigation no longer immediately commits the language change and closes the settings dialog. Users can now browse languages with arrow keys and confirm with Enter/Space/Escape.
  • Remove duplicate zh-CN entry: Remove zh-CN from SupportedLocales since it's a child culture of zh-Hans (which is already listed). This eliminates the duplicate "中文 中国" option in the language dropdown.
  • Add OptionValue binding: Add OptionValue="@(c => c!.Name)" to the FluentSelect to ensure correct value matching by culture name.
  • Walk parent culture chain: Add IsSupportedCulture method that walks the culture parent chain so zh-CN (and similar regional variants) are still recognized as supported via their parent zh-Hans.
  • Set dynamic lang attribute: Change <html lang="en"> to <html lang="@System.Globalization.CultureInfo.CurrentUICulture.Name"> so the HTML lang attribute reflects the actual UI culture.
  • Add tests: New tests for unique display names, zh-CN resolution, and Accept-Language header matching.
language-dropdown-open
language-dropdown-demo.webm

Fixes #12479
Fixes #15897

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 12, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16094

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16094"

@adamint
Copy link
Copy Markdown
Member Author

adamint commented Apr 12, 2026

Screenshots

Settings dialog with language dropdown open (no duplicate zh-CN)

Screenshot and video need to be manually attached — drag and drop the files below into this comment:

  • /tmp/language-dropdown-open.png
  • /tmp/language-dropdown-demo.webm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves Aspire Dashboard localization UX by preventing accidental language commits via arrow keys in the Settings dialog, removing a duplicated Chinese locale entry, and ensuring culture resolution still recognizes regional variants like zh-CN.

Changes:

  • Update the Settings dialog language FluentSelect to commit selection on Enter and bind option identity by culture name.
  • Remove zh-CN from the base supported locale list while adding parent-culture-chain matching so zh-CN still resolves via zh-Hans.
  • Add tests covering unique display names and zh-CN / Accept-Language matching behavior; set the document lang attribute dynamically.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/Aspire.Dashboard.Tests/GlobalizationHelpersTests.cs Adds regression tests for unique language display names and zh-CN resolution via Accept-Language and parent culture matching.
src/Shared/LocaleHelpers.cs Removes zh-CN from SupportedLocales and adds parent-chain support when validating locale overrides.
src/Aspire.Dashboard/Components/Dialogs/SettingsDialog.razor Prevents arrow-key navigation from immediately committing language changes; adds OptionValue for stable matching.
src/Aspire.Dashboard/Components/App.razor Makes the root <html lang> reflect the active UI culture.

Comment on lines +53 to +65
// Walk the parent chain to find a supported culture.
// For example, zh-CN's parent is zh-Hans which is supported.
var current = cultureInfo.Parent;
var depth = 0;
while (current != CultureInfo.InvariantCulture && depth < 5)
{
if (SupportedLocales.Contains(current.Name))
{
return true;
}
current = current.Parent;
depth++;
}
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

IsSupportedCulture hard-codes the parent-chain depth limit (depth < 5). This makes the rationale less clear and duplicates the same limit used elsewhere (e.g., GlobalizationHelpers). Consider extracting this into a named constant (and/or breaking on current == current.Parent) so the loop’s termination condition is self-documenting and easier to adjust in one place.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch! Extracted MaxCultureParentDepth as a named constant (matching GlobalizationHelpers) and added a current != current.Parent guard against circular parent chains.

@adamint adamint self-assigned this Apr 12, 2026
@JamesNK JamesNK enabled auto-merge (squash) April 13, 2026 02:05
@JamesNK JamesNK merged commit ace6fe5 into microsoft:main Apr 13, 2026
552 of 555 checks passed
@joperezr joperezr added this to the 13.3 milestone Apr 14, 2026
radical pushed a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants