fixes #2539, show all possible font weight options for local fonts or unknown fontFamily

This commit is contained in:
Amruth Pillai
2026-01-23 02:04:11 +01:00
parent 11cbeb27f8
commit 6658412f8b
2 changed files with 12 additions and 5 deletions
+10 -2
View File
@@ -63,9 +63,17 @@ type FontWeightComboboxProps = Omit<MultipleComboboxProps, "options"> & { fontFa
export function FontWeightCombobox({ fontFamily, ...props }: FontWeightComboboxProps) {
const options = useMemo(() => {
const fontData = webFontMap.get(fontFamily);
if (!fontData || !Array.isArray(fontData.weights)) return [];
return fontData.weights.map((variant: string) => ({
let weights: string[] = [];
if (!fontData || !Array.isArray(fontData.weights)) {
// Provide all possible options for local fonts or unknown fontFamily
weights = ["100", "200", "300", "400", "500", "600", "700", "800", "900"];
} else {
weights = fontData.weights as string[];
}
return weights.map((variant: string) => ({
value: variant,
label: variant,
keywords: [variant],
+2 -3
View File
@@ -117,11 +117,10 @@ function Combobox<TValue extends string | number = string>({
<PopoverContent
align="start"
aria-disabled={disabled}
tabIndex={disabled ? -1 : undefined}
className={cn("min-w-[200px] p-0", className, disabled && "pointer-events-none select-none opacity-60")}
{...props}
// Hide popover content visually and functionally if disabled (prevent tab focus etc)
tabIndex={disabled ? -1 : undefined}
aria-disabled={disabled}
>
<Command>
<CommandInput placeholder={searchPlaceholder} disabled={disabled} />