Skip to content

Commit 1584587

Browse files
author
Eric Wheeler
committed
fix: language selection display in CodeBlock
Fixes issue where language selection dropdown would display truncated language names and not properly update UI state after selection. Signed-off-by: Eric Wheeler <[email protected]>
1 parent 6b44cd4 commit 1584587

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

webview-ui/src/components/common/CodeBlock.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -641,28 +641,33 @@ const CodeBlock = memo(
641641
// Display original language at top of list for quick selection
642642
language && (
643643
<option
644-
value={language}
644+
value={normalizeLanguage(language)}
645645
style={{ fontWeight: "bold", textAlign: "left", fontSize: "1.2em" }}>
646-
{language}
646+
{normalizeLanguage(language)}
647647
</option>
648648
)
649649
}
650650
{
651651
// Display all available languages in alphabetical order
652652
Object.keys(bundledLanguages)
653653
.sort()
654-
.map((lang) => (
655-
<option
656-
key={lang}
657-
value={lang}
658-
style={{
659-
fontWeight: lang === language ? "bold" : "normal",
660-
textAlign: "left",
661-
fontSize: lang === language ? "1.2em" : "inherit",
662-
}}>
663-
{lang}
664-
</option>
665-
))
654+
.map((lang) => {
655+
const normalizedLang = normalizeLanguage(lang)
656+
return (
657+
<option
658+
key={normalizedLang}
659+
value={normalizedLang}
660+
style={{
661+
fontWeight:
662+
normalizedLang === currentLanguage ? "bold" : "normal",
663+
textAlign: "left",
664+
fontSize:
665+
normalizedLang === currentLanguage ? "1.2em" : "inherit",
666+
}}>
667+
{normalizedLang}
668+
</option>
669+
)
670+
})
666671
}
667672
</LanguageSelect>
668673
)}

0 commit comments

Comments
 (0)