fix(components): [tree-select] fix filter no matching data error (#17473)

* fix(components): [tree-select] fix filter no matching data error

* fix: immediate
This commit is contained in:
赵添 2024-07-09 19:01:32 +08:00 committed by GitHub
parent 6032af5405
commit fc15cad898
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View File

@ -225,6 +225,10 @@ describe('TreeSelect.vue', () => {
tree.vm.filter('一级 1')
await nextTick()
expect(tree.findAll('.el-tree-node:not(.is-hidden)').length).toBe(1)
expect(document.querySelector('.el-select-dropdown__empty')).toBeFalsy()
tree.vm.filter('no match')
await nextTick()
expect(document.querySelector('.el-select-dropdown__empty')).toBeTruthy()
})
test('props', async () => {

View File

@ -1,4 +1,4 @@
import { defineComponent, getCurrentInstance, nextTick } from 'vue'
import { defineComponent, getCurrentInstance, nextTick, watch } from 'vue'
import { ElOption } from '@element-plus/components/select'
const component = defineComponent({
@ -26,6 +26,16 @@ const component = defineComponent({
}
})
watch(
() => ctx.attrs.visible,
(val) => {
result.states.visible = val
},
{
immediate: true,
}
)
return result
},
methods: {

View File

@ -138,6 +138,7 @@ export const useTree = (
value: getNodeValByProp('value', data),
label: getNodeValByProp('label', data),
disabled: getNodeValByProp('disabled', data),
visible: node.visible,
},
props.renderContent
? () => props.renderContent(h, { node, data, store })