Bug description
Hi, after 2.6.1 symfony-ux-autocomplete with lazy loading broke for me, claude helped me put together a reproducer: https://github.com/mmarton/tomselect-2.6.1-bug-repro
AI explanation below:
Root cause: PR #998 ("losing preloaded options after search") in Tom Select 2.6.1 added this block to src/plugins/virtual_scroll/plugin.ts:
if (!loading_more && !default_values_loaded) {
default_values_loaded = true;
if (self.lastValue === '') {
default_values = Object.keys(self.options); // ← captures ALL preloaded keys
default_pagination = pagination[''];
}
}
Why this breaks ux-autocomplete's "lazy + filter" flow:
The virtual_scroll plugin already had a clearFilter used between loads:
const clearFilter = (option, value) =>
self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0;
This keeps any option whose key is in default_values.
- 2.6.0: default_values was set only on initialize → contains only static <option> keys (empty for a lazy entity field). When the user types, clearOptions(clearFilter) clears the preloaded
results, then the server's filtered results arrive → dropdown shows only the matches. ✅
- 2.6.1: after the initial preload, default_values is overwritten with the keys of every preloaded option. Now clearFilter keeps all of them during search. The newly loaded filtered results
are merged on top, and Symfony UX uses score: () => () => 1 (server-side filtering, no client filter). Result: every preloaded item plus the server-filtered ones are displayed regardless of
the query. ❌
Expected behavior
same as in 2.6.0, filtering shows only the relevant results
Steps to reproduce
- checkout my repo
- run it
...
X. See error
Additional context
not relevant, but
- OS:linux mint 22.3
- Browser firefox
- Version 151
- Device: laptop
Bug description
Hi, after 2.6.1 symfony-ux-autocomplete with lazy loading broke for me, claude helped me put together a reproducer: https://github.com/mmarton/tomselect-2.6.1-bug-repro
AI explanation below:
Expected behavior
same as in 2.6.0, filtering shows only the relevant results
Steps to reproduce
...
X. See error
Additional context
not relevant, but