Skip to content

Commit 7842206

Browse files
rdjanuarzernonia
andauthored
fix(Tree): issue selection item with v-model (#2040)
* fix(Tree): issue selection item with v-model * fix(Tree): remove unnecessary log * fix: revert changes to expanded --------- Co-authored-by: zernonia <zernonia@gmail.com>
1 parent 47c199b commit 7842206

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/core/src/Tree/TreeRoot.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface TreeRootProps<T = Record<string, any>, U extends Record<string,
2121
/** How multiple selection should behave in the collection. */
2222
selectionBehavior?: 'toggle' | 'replace'
2323
/** Whether multiple options can be selected or not. */
24-
multiple?: M
24+
multiple?: M | boolean
2525
/** The reading direction of the listbox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */
2626
dir?: Direction
2727
/** When `true`, prevents the user from interacting with tree */
@@ -112,7 +112,7 @@ const virtualKeydownHook = createEventHook<KeyboardEvent>()
112112
const modelValue = useVModel(props, 'modelValue', emits, {
113113
// @ts-expect-error idk
114114
defaultValue: props.defaultValue ?? (multiple.value ? [] : undefined),
115-
passive: (props.modelValue === undefined) as false,
115+
passive: true,
116116
deep: true,
117117
}) as Ref<U | U[]>
118118

packages/core/src/Tree/story/TreeCheckbox.story.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<script setup lang="ts">
22
import { Icon } from '@iconify/vue'
3+
import { ref } from 'vue'
34
import { TreeItem, TreeRoot } from '..'
45
import { items } from './constants'
6+
7+
const models = ref([])
58
</script>
69

710
<template>
@@ -12,6 +15,7 @@ import { items } from './constants'
1215
<Variant title="default">
1316
<TreeRoot
1417
v-slot="{ flattenItems }"
18+
v-model="models"
1519
class="list-none select-none w-64 bg-white text-blackA11 rounded-lg p-2 text-sm font-medium"
1620
:items="items"
1721
:get-key="(item) => item.title"

0 commit comments

Comments
 (0)