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,11 +103,13 @@
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
.sort((a: Driver, b: Driver) => a.firstname.localeCompare(b.firstname))
.map((driver: Driver) => {
return { return {
// NOTE: Because Skeleton displays the values inside the autocomplete input, // NOTE: Because Skeleton displays the values inside the autocomplete input,
// we have to supply the driver code twice and manage a list of ids manually (ugh) // we have to supply the driver code twice and manage a list of ids manually (ugh)
label: driver.code, label: `${driver.firstname} ${driver.lastname}`,
value: driver.code, value: driver.code,
}; };
}); });
@ -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;