update to simpler sorting

This commit is contained in:
Arthur
2026-01-14 14:21:43 -08:00
parent 5a1282e326
commit 20f52153a4
4 changed files with 9 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -102,14 +102,10 @@ export class DynamicTomSelect extends TomSelect {
.then(apiData => {
const results: Dict[] = apiData.results;
// Add options and set $order to preserve API response order
results.forEach((result, index) => {
// Add options (TomSelect automatically preserves insertion order via $order)
results.forEach((result) => {
const option = self.getOptionFromData(result);
self.addOption(option);
const key = option[self.settings.valueField as string] as string;
if (self.options[key]) {
(self.options[key] as any).$order = index;
}
});
if (self.loading > 0) {

View File

@@ -49,6 +49,9 @@ export function initDynamicSelects(): void {
labelField: LABEL_FIELD,
maxOptions: MAX_OPTIONS,
// Preserve API response order
sortField: '$order',
// Disable local search (search is performed on the backend)
searchField: [],