Fix language dropdown arrow-key behavior and duplicate zh-CN entry in dashboard settings#16094
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16094Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16094" |
ScreenshotsSettings 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:
|
There was a problem hiding this comment.
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
FluentSelectto commit selection on Enter and bind option identity by culture name. - Remove
zh-CNfrom the base supported locale list while adding parent-culture-chain matching sozh-CNstill resolves viazh-Hans. - Add tests covering unique display names and
zh-CN/Accept-Languagematching behavior; set the documentlangattribute 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. |
| // 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++; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good catch! Extracted MaxCultureParentDepth as a named constant (matching GlobalizationHelpers) and added a current != current.Parent guard against circular parent chains.
… dashboard settings (#16094)
Description
Fixes the language dropdown in the dashboard settings and zh-CN locale handling.
Changes
Immediate="true"withChangeOnEnterOnly="true"on the languageFluentSelectso 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.zh-CNfromSupportedLocalessince it's a child culture ofzh-Hans(which is already listed). This eliminates the duplicate "中文 中国" option in the language dropdown.OptionValuebinding: AddOptionValue="@(c => c!.Name)"to theFluentSelectto ensure correct value matching by culture name.IsSupportedCulturemethod that walks the culture parent chain sozh-CN(and similar regional variants) are still recognized as supported via their parentzh-Hans.langattribute: Change<html lang="en">to<html lang="@System.Globalization.CultureInfo.CurrentUICulture.Name">so the HTML lang attribute reflects the actual UI culture.language-dropdown-demo.webm
Fixes #12479
Fixes #15897