Skip to content

Commit 80ab23f

Browse files
committed
docs(use-proxy-model): document disabled ref unwrapping on initial registration
1 parent 88feee7 commit 80ab23f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

apps/docs/src/pages/composables/reactivity/use-proxy-model.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ const props = defineProps<{ multiple?: boolean }>()
7676
const stop = useProxyModel(selection, model, { multiple: () => props.multiple ?? false })
7777
```
7878

79+
### Disabled items
80+
81+
When a new item registers with the selection, `useProxyModel` checks whether the model already holds that item's value and selects it if so — this is how items that were selected before they mounted get their initial state. The check is skipped if the item is disabled. The `disabled` property is automatically unwrapped if it is a `Ref<boolean>`:
82+
83+
```ts no-filename
84+
selection.onboard([
85+
{ id: 'a', value: 'A' },
86+
{ id: 'b', value: 'B', disabled: ref(true) }, // reactive disabled
87+
])
88+
89+
model.value = 'B'
90+
// 'b' is NOT auto-selected because disabled is true at registration time
91+
```
92+
7993
## Architecture
8094

8195
`useProxyModel` creates bidirectional sync between v-model refs and selection state:

0 commit comments

Comments
 (0)