Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox/item): fix some items not add into allItems map #1368

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 13 additions & 3 deletions packages/core/src/Combobox/ComboboxItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ if (!props.value) {
}

const isRender = computed(() => {
if (rootContext.isVirtual.value || rootContext.ignoreFilter.value || !rootContext.filterState.search)
if (rootContext.isVirtual.value || rootContext.ignoreFilter.value || !rootContext.filterState.search) {
return true
else
return rootContext.filterState.filtered.items.get(id)! > 0
}
else {
const filteredCurrentItem = rootContext.filterState.filtered.items.get(id)
// If the filtered items is undefined means not in the all times map yet
// Do the first render to add into the map
if (filteredCurrentItem === undefined) {
return true
}

// Check with filter
return filteredCurrentItem > 0
}
})

onMounted(() => {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/Combobox/ComboboxRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ watch(() => open.value, () => {
})
}, { flush: 'post' })
watch(() => allItems.value.size, (val) => {
RayGuo-ergou marked this conversation as resolved.
Show resolved Hide resolved
filterItems()
})
defineExpose({
highlightedElement,
highlightItem: primitiveElement.value?.highlightItem,
Expand Down
Loading