[ bug ] Select 使用 filterable属性后,选择某项后,列表只展示一项
官网 https://www.iviewui.com/view-ui-plus/component/form/select#filterable 点击在 Playground 中打开 可复现
Hello @luo772435545! I'm Dosu, your friendly bot here to help you tackle bugs, answer questions, and make contributing a breeze while you wait for a human maintainer. Let's get started! 🚀
I found a similar open issue regarding the filterable attribute in the Select component: [Bug Report] Select 组件的 filterable 属性在 1.3.5 版本后失效 [1]. This issue is still open and has no comments or references.
To resolve the issue where the Select component with the filterable attribute only displays one item after selection, ensure that the query is reset appropriately when a selection is made. The code should reset the query when values change, especially for multiple selections. Here's a relevant code snippet:
watch: {
values ([value]) {
if (!this.filterable) return;
this.preventRemoteCall = true;
if (this.multiple){
this.query = '';
this.preventRemoteCall = false; // this should be after the query change setter above
return;
}
if (typeof value === 'undefined' || value === '' || value === null) this.query = '';
else this.query = value.label;
nextTick(() => this.preventRemoteCall = false); // this should be after the query change setter above
},
query (val) {
if (this.preventRemoteCall) {
this.preventRemoteCall = false;
return;
}
this.$emit('on-query-change', val);
},
queryProp (query ){
if (query !== this.query) this.query = query;
},
}
Ensure that the query is reset to an empty string when a selection is made, especially for multiple selections [2].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other