Repository navigation
fix(language-select): hide raw language code from translate selector trigger - #21993
Merged
DeJeune merged 2 commits intoOct 19, 2026
Merged
Conversation
…trigger With searchPlacement='trigger', the closed combobox renders an input whose value is selectedOption.label. LanguageSelect built that label from searchText (code + flag + name), so the closed selector showed e.g. 'zh-cn 🇨🇳 简体中文'. Use a display label of flag + localized name; the code-bearing string stays in searchText for filtering. Refs CherryHQ#21967 Signed-off-by: zzx04-cool <[email protected]>
Assert the closed selector shows flag + localized name without the raw code (fails before the fix), and that typing a language code still finds and selects the language. Refs CherryHQ#21967 Signed-off-by: zzx04-cool <[email protected]>
There was a problem hiding this comment.
Technical review supports approval at 39b30b3de92e7efc1819c495cdc8ce7a5b2ff714. No confirmed defects: the selector displays flag plus localized name while preserving code search and selection values. Reviewed the full diff, Combobox contract, and all LanguageSelect consumers.
Frozen-head CI at 2026-10-19 08:58 UTC: 10 successful checks, six skipped, and cherry-review in progress; no failures. Legacy status has zero contexts. Reviewer A reports six focused tests passed across two files; the Lead performed static verification and scope checks without rerunning tests or Electron visual checks.
Cherry Review · Passed
no findings
DeJeune
approved these changes
Oct 19, 2026
4 of 7 tasks
ShuaiHui
pushed a commit
to xigaomeicun/cherry-lite
that referenced
this pull request
Oct 20, 2026
…trigger (CherryHQ#21993) ### What this PR does Before this PR: - The translate target-language selector (`LanguageSelect` with `searchPlacement="trigger"`) showed the raw language code in front of the flag and localized name while closed, e.g. `zh-cn 🇨🇳 简体中文` or `ja-jp 🇯🇳 日文`. - In trigger-search mode the closed combobox renders an `<input>` whose value is `selectedOption.label` (`packages/ui/src/components/primitives/combobox.tsx`), and `LanguageSelect` built that `label` from `searchText` (code + flag + name). The `renderValue` prop (flag + name only) applies solely to the button trigger, so it never took effect here. After this PR: - Each language option carries a display `label` of flag + localized name (`🇨🇳 简体中文`), matching the dropdown options and the `renderValue` output. - The code-bearing string remains in `searchText`, and `filterOption` still matches against `searchText` and the option value, so typing a language code (e.g. `zh-cn`) still finds the language. Fixes CherryHQ#21967 ### Why we need it and why it was done in this way The following tradeoffs were made: - The display label is a plain string (`flag + name`) because the trigger-search input can only render a string value; the rich JSX rendering (`content`) continues to be used inside the dropdown and by `renderValue`. - Only language options changed. `extraOptionsBefore/After` already build their label from the plain display text with no code prefix, so they were left untouched. The following alternatives were considered: - Changing the shared `Combobox` to use `renderValue` for the closed trigger input. That would alter a shared primitive used across the app and would also need a string fallback for the input, for a bug that is specific to how `LanguageSelect` constructs its labels. Keeping the change in `LanguageSelect` is the smaller, lower-risk fix. Links to places where the discussion took place: CherryHQ#21967 (root cause and fix direction identified there). ### Agent Note / Spec Agent Note: N/A — one-line, localized UI bug fix on an existing component; the issue already located the exact cause and direction, no Spec needed. Spec PR: N/A Acceptance criteria: N/A — direct bug fix; verified by the two regression cases noted below (closed selector shows flag + name only; code search still works). ### Verification - Environment: Node v24.22.0, pnpm 12.6.0 (corepack), Windows 11 (10.0.26200), AMD64. - Baseline before changes: `pnpm test:renderer src/renderer/components/__tests__/LanguageSelect.test.tsx` → 1 pass, 0 fail. - `pnpm test:renderer src/renderer/components/__tests__/LanguageSelect.test.tsx src/renderer/windows/quickAssistant/translate/__tests__/TranslateWindow.test.tsx` → 2 files, 6 pass, 0 fail. - Regression check: with the one-line fix reverted, the new closed-selector test fails (`zh-cn 🇨🇳 Chinese` received instead of `🇨🇳 Chinese`); the code-search test stays green. With the fix in place, all 3 tests pass. - `pnpm check --group types` (selected scope: renderer, `tsc --noEmit -p tsconfig.web.json`) → passed. - `pnpm check --group i18n` → passed (89062 translation entries verified; 0 unused keys; no hardcoded strings). - `pnpm exec oxlint --deny-warnings <changed files>` → 0 warnings, 0 errors; `pnpm exec eslint <changed files>` → clean; `pnpm exec oxfmt --check <changed files>` → correct format. - The full local suite was not run per the repository's scoped local-PR validation guidance; CI will run the full gate once a maintainer approves. ### Breaking changes None. The option `value` and `searchText` are unchanged; only the closed-trigger display string changes. ### Special notes for your reviewer - Diff is 1 production line plus 18 test lines (`src/renderer/components/LanguageSelect.tsx` and its existing test file). - Commits include DCO `Signed-off-by`; GPG/SSH cryptographic signing is not configured on this machine. ### Checklist - [x] Branch: This PR targets `main` - [x] PR: The PR description is explicit enough and will help future contributors - [x] Code: Write code that humans can understand and Keep it simple - [x] Refactor: You have left the code cleaner than you found it (Boy Scout Rule) - [x] Upgrade: Impact of this change on upgrade flows was considered and addressed if required - [x] Documentation: A user-guide update was considered; this fixes a selector display detail and adds no new setting or workflow, so no docs update is required. - [x] Self-review: I have reviewed my own code (e.g., via `/gh-pr-review`, `git pr diff`, or GitHub UI) before requesting review from others ### Release note ```release-note Translate: the target-language selector no longer shows the raw language code (e.g. "zh-cn") before the flag and language name when closed. ``` --------- Signed-off-by: zzx04-cool <[email protected]> Co-authored-by: zzx04-cool <[email protected]> (cherry picked from commit dcab4fe)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Before this PR:
LanguageSelectwithsearchPlacement="trigger") showed the raw language code in front of the flag and localized name while closed, e.g.zh-cn 🇨🇳 简体中文orja-jp 🇯🇳 日文.<input>whose value isselectedOption.label(packages/ui/src/components/primitives/combobox.tsx), andLanguageSelectbuilt thatlabelfromsearchText(code + flag + name). TherenderValueprop (flag + name only) applies solely to the button trigger, so it never took effect here.After this PR:
labelof flag + localized name (🇨🇳 简体中文), matching the dropdown options and therenderValueoutput.searchText, andfilterOptionstill matches againstsearchTextand the option value, so typing a language code (e.g.zh-cn) still finds the language.Fixes #21967
Why we need it and why it was done in this way
The following tradeoffs were made:
flag + name) because the trigger-search input can only render a string value; the rich JSX rendering (content) continues to be used inside the dropdown and byrenderValue.extraOptionsBefore/Afteralready build their label from the plain display text with no code prefix, so they were left untouched.The following alternatives were considered:
Comboboxto userenderValuefor the closed trigger input. That would alter a shared primitive used across the app and would also need a string fallback for the input, for a bug that is specific to howLanguageSelectconstructs its labels. Keeping the change inLanguageSelectis the smaller, lower-risk fix.Links to places where the discussion took place: #21967 (root cause and fix direction identified there).
Agent Note / Spec
Agent Note: N/A — one-line, localized UI bug fix on an existing component; the issue already located the exact cause and direction, no Spec needed.
Spec PR: N/A
Acceptance criteria: N/A — direct bug fix; verified by the two regression cases noted below (closed selector shows flag + name only; code search still works).
Verification
pnpm test:renderer src/renderer/components/__tests__/LanguageSelect.test.tsx→ 1 pass, 0 fail.pnpm test:renderer src/renderer/components/__tests__/LanguageSelect.test.tsx src/renderer/windows/quickAssistant/translate/__tests__/TranslateWindow.test.tsx→ 2 files, 6 pass, 0 fail.zh-cn 🇨🇳 Chinesereceived instead of🇨🇳 Chinese); the code-search test stays green. With the fix in place, all 3 tests pass.pnpm check --group types(selected scope: renderer,tsc --noEmit -p tsconfig.web.json) → passed.pnpm check --group i18n→ passed (89062 translation entries verified; 0 unused keys; no hardcoded strings).pnpm exec oxlint --deny-warnings <changed files>→ 0 warnings, 0 errors;pnpm exec eslint <changed files>→ clean;pnpm exec oxfmt --check <changed files>→ correct format.Breaking changes
None. The option
valueandsearchTextare unchanged; only the closed-trigger display string changes.Special notes for your reviewer
src/renderer/components/LanguageSelect.tsxand its existing test file).Signed-off-by; GPG/SSH cryptographic signing is not configured on this machine.Checklist
main/gh-pr-review,git pr diff, or GitHub UI) before requesting review from othersRelease note