diff --git a/src/lib/Combobox.svelte b/src/lib/Combobox.svelte index 806a2ef..a026914 100644 --- a/src/lib/Combobox.svelte +++ b/src/lib/Combobox.svelte @@ -29,10 +29,11 @@ }; /** returns option label, falling back to value or 'Undefined Option' if no option provided */ - const getLabel = (opt: ComboboxOption | undefined): string => + const getLabel = (opt: ComboboxOption | undefined | null): string => opt ? (opt.label ?? opt.value) : 'Undefined Option'; /** returns option preview, falling back to getLabel if missing */ - const getPreview = (opt: ComboboxOption | undefined): string => opt?.preview ?? getLabel(opt); + const getPreview = (opt: ComboboxOption | undefined | null): string => + opt?.preview ?? getLabel(opt);