Merge pull request #3663 from SergioCrisostomo/refactor-select

Allow wider search pattern for filterable
This commit is contained in:
Aresn 2018-05-22 10:41:53 +08:00 committed by GitHub
commit d322bd7d08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -434,11 +434,15 @@
}; };
}, },
validateOption({elm, propsData}){ validateOption({children, elm, propsData}){
if (this.queryStringMatchesSelectedOption) return true; if (this.queryStringMatchesSelectedOption) return true;
const value = propsData.value; const value = propsData.value;
const label = propsData.label || ''; const label = propsData.label || '';
const textContent = elm && elm.textContent || ''; const textContent = (elm && elm.textContent) || (children || []).reduce((str, node) => {
const nodeText = node.elm ? node.elm.textContent : node.text;
return `${str} ${nodeText}`;
}, '') || '';
const stringValues = JSON.stringify([value, label, textContent]); const stringValues = JSON.stringify([value, label, textContent]);
const query = this.query.toLowerCase().trim(); const query = this.query.toLowerCase().trim();
return stringValues.toLowerCase().includes(query); return stringValues.toLowerCase().includes(query);