Skip to content

Select组件和TreeSelect组件的自定义filter方法bug #7034

@1020847665

Description

@1020847665

Describe the bug

当Select组件和TreeSelect组件 输入框删除最后一个字符的时候未执行filter方法

Steps to reproduce

1.如selet.tsx 313行
2. const filteredOptionsRef = computed(() => {
if (props.remote) {
return compitableOptionsRef.value
}
else {
const { value: localOptions } = localOptionsRef
const { value: pattern } = patternRef
if (!pattern.length || !props.filterable) {
return localOptions
}
else {
return filterOptions(
localOptions,
resolvedFilterRef.value,
pattern,
props.childrenField
)
}
}
})

3.当filter方法的执行是在filterOptions方法里面,但是当删除最后一个字符时,先执行了if (!pattern.length || !props.filterable)这个分支不走else分支,使filter方法未执行,致使用户传递的filter方法不能监听到删除最后一个字符的情况

Link to minimal reproduction

naive-ui-main\src\select\src\Select.tsx

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
    Memory: 3.84 GB / 15.62 GB
  Binaries:
    Node: 20.18.0 - ~\bin\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs-all\nodejs-v16.19.0-x64\yarn.CMD
    npm: 10.8.2 - ~\bin\npm.CMD
    pnpm: 8.10.5 - C:\Program Files\nodejs-all\nodejs-v16.19.0-x64\pnpm.CMD
  Browsers:
    Internet Explorer: 11.0.19041.3636

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions