fix: don't auto-select glossary when no target language match
When activating the glossary toggle, only auto-select a glossary if it matches BOTH source and target language. If no matching glossary exists (e.g. translating to Persian but only have FR→EN glossaries), leave the selector empty so the user picks manually instead of forcing an incompatible glossary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -284,10 +284,13 @@ export function GlossarySelector({ sourceLang, targetLang, isPro, mode, glossary
|
|||||||
setIsGlossaryEnabled(nextVal);
|
setIsGlossaryEnabled(nextVal);
|
||||||
if (!nextVal) {
|
if (!nextVal) {
|
||||||
onChange(null);
|
onChange(null);
|
||||||
} else if (filteredGlossaries.length > 0 && !glossaryId) {
|
} else if (!glossaryId) {
|
||||||
// Prefer glossary matching target language, fall back to first
|
// Only auto-select if a glossary matches BOTH source and target language
|
||||||
const matching = filteredGlossaries.find(g => g.target_language === targetLang);
|
const matching = filteredGlossaries.find(g => g.target_language === targetLang);
|
||||||
onChange(matching ? matching.id : filteredGlossaries[0].id);
|
if (matching) {
|
||||||
|
onChange(matching.id);
|
||||||
|
}
|
||||||
|
// If no glossary matches the target, leave unselected — user picks manually
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
Reference in New Issue
Block a user