SEV-392: combobox setOptions() for reactive parent-fed option lists
Passing a parent component's reactive array into the nested combobox x-data needs x-effect="setOptions(vpicMakes)" — a plain closure over the parent scope doesn't track Alpine updates. Falls back to config.options for static lists. 18/18 tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,3 +54,13 @@ test('empty query lists all options (capped) (SEV-392)', () => {
|
||||
c.query = '';
|
||||
assert.equal(c.filtered.length, 3);
|
||||
});
|
||||
|
||||
test('setOptions feeds reactive option lists (SEV-392)', () => {
|
||||
const c = comboboxData({ allowFree: true });
|
||||
c.setOptions([]); // async source not loaded yet
|
||||
assert.equal(c.filtered.length, 0);
|
||||
c.setOptions(['BMW', 'Tesla']); // makes arrive
|
||||
assert.equal(c.filtered.length, 2);
|
||||
c.query = 'tes';
|
||||
assert.deepEqual(c.filtered.map((o) => o.value), ['Tesla']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user