Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions apps/web/src/components/settings/FontFamilyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ComboboxTrigger,
} from "../ui/combobox";
import { SelectButton } from "../ui/select";
import { stackedThreadToast, toastManager } from "../ui/toast";

const DEFAULT_FONT_VALUE = "__default__";

Expand Down Expand Up @@ -141,8 +142,8 @@ export function FontFamilyPicker({

const families = useMemo(() => {
if (enumeration.status !== "granted") return [];
return requireMonospace ? enumeration.families.filter(isMonospaceFamily) : enumeration.families;
}, [enumeration, requireMonospace]);
return enumeration.families;
}, [enumeration]);

const items = useMemo(() => {
const trimmedQuery = query.trim().toLowerCase();
Expand All @@ -160,6 +161,16 @@ export function FontFamilyPicker({

const handlePick = (value: string) => {
setOpen(false);
if (value !== DEFAULT_FONT_VALUE && requireMonospace && !isMonospaceFamily(value)) {
toastManager.add(
stackedThreadToast({
type: "error",
title: `"${value}" isn't monospace`,
description: "Code and terminal need a fixed-width font, so the current font was kept.",
}),
);
return;
}
onSelect(value === DEFAULT_FONT_VALUE ? "" : value);
};

Expand Down
Loading