Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/aria/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export class Listbox<V> implements OnDestroy {
/** Whether focus should wrap when navigating. */
readonly wrap = input(true, {transform: booleanAttribute});

/** Whether the value should always be in sync with the available options */
readonly syncValue = input(true, {transform: booleanAttribute});

/**
* Whether to allow disabled items to receive focus. When `true`, disabled items are
* focusable but not interactive. When `false`, disabled items are skipped during navigation.
Expand Down Expand Up @@ -190,8 +193,9 @@ export class Listbox<V> implements OnDestroy {
write: () => {
const items = inputs.items();
const value = untracked(() => this.value());
const syncValue = untracked(() => this.syncValue());

if (items && value.some(v => !items.some(i => i.value() === v))) {
if (syncValue && items && value.some(v => !items.some(i => i.value() === v))) {
this.value.set(value.filter(v => items.some(i => i.value() === v)));
}
},
Expand Down
Loading