iview [Bug Report]Select Component Bug When Open filterable And Change The Options

oymdgrw7  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(62)

Environment

iview 3.0.1 2.14.3

https://jsfiddle.net/FifteenZhang/eywraw8t/307401/

Steps to reproduce

1.Open the Select DropList.Then Close it.
2.Click the Button.
3.There is the bug. The text is "select-not-found"

What is expected?

The select options can be displayed as expected.

What is actually happening?

The text is "select-not-found" and the options don't show.

the query text isn't be changed when the options changes.

dm7nw8vv

dm7nw8vv2#

看了一下源码,这个问题是由于validateOption方法返回结果有误的问题。

validateOption({children, elm, propsData}){
                if (this.queryStringMatchesSelectedOption) return true;

                const value = propsData.value;
                const label = propsData.label || '';
                const textContent = (elm && elm.textContent) || (children || []).reduce((str, node) => {
                    const nodeText = node.elm ? node.elm.textContent : node.text;
                    return `${str} ${nodeText}`;
                }, '') || '';
                // 下面就是bug产生的原因,query值还是旧值未清空,stringValues已经更换为新的值了,导致返回false,进而导致问题的出现。
                const stringValues = JSON.stringify([value, label, textContent]);
                const query = this.query.toLowerCase().trim();
                return stringValues.toLowerCase().includes(query);
            },

相关问题