Lib: Sort driver options in RaceResultCard

This commit is contained in:
2025-02-26 23:37:06 +01:00
parent 08774fc40b
commit dcd62cdbfa

View File

@ -103,14 +103,16 @@
active_and_substitutes[for_index] = (drivers ?? [])[sub_index]; active_and_substitutes[for_index] = (drivers ?? [])[sub_index];
}); });
return active_and_substitutes.map((driver: Driver) => { return active_and_substitutes
return { .sort((a: Driver, b: Driver) => a.firstname.localeCompare(b.firstname))
// NOTE: Because Skeleton displays the values inside the autocomplete input, .map((driver: Driver) => {
// we have to supply the driver code twice and manage a list of ids manually (ugh) return {
label: driver.code, // NOTE: Because Skeleton displays the values inside the autocomplete input,
value: driver.code, // we have to supply the driver code twice and manage a list of ids manually (ugh)
}; label: `${driver.firstname} ${driver.lastname}`,
}); value: driver.code,
};
});
}); });
let pxxs_whitelist: string[] = $derived.by(() => let pxxs_whitelist: string[] = $derived.by(() =>
@ -121,7 +123,7 @@
// Event handlers // Event handlers
const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => { const on_pxxs_chip_select = (event: CustomEvent<AutocompleteOption<string>>): void => {
if (disabled || !currentrace || !drivers) return; if (disabled || !drivers) return;
// Can only select 7 drivers // Can only select 7 drivers
if (pxxs_chips.length >= 7) return; if (pxxs_chips.length >= 7) return;