mirror of https://github.com/ElemeFE/element
Select: fix an illegal filter regexp bug
parent
fad0fd320c
commit
aa27888a58
|
@ -3,7 +3,7 @@
|
||||||
@mouseenter="hoverItem"
|
@mouseenter="hoverItem"
|
||||||
@click.stop="selectOptionClick"
|
@click.stop="selectOptionClick"
|
||||||
class="el-select-dropdown__item"
|
class="el-select-dropdown__item"
|
||||||
v-show="queryPassed"
|
v-show="visible"
|
||||||
:class="{ 'selected': itemSelected, 'is-disabled': disabled || groupDisabled, 'hover': parent.hoverIndex === index }">
|
:class="{ 'selected': itemSelected, 'is-disabled': disabled || groupDisabled, 'hover': parent.hoverIndex === index }">
|
||||||
<slot>
|
<slot>
|
||||||
<span>{{ currentLabel }}</span>
|
<span>{{ currentLabel }}</span>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
return {
|
return {
|
||||||
index: -1,
|
index: -1,
|
||||||
groupDisabled: false,
|
groupDisabled: false,
|
||||||
queryPassed: true,
|
visible: true,
|
||||||
hitState: false
|
hitState: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -97,8 +97,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
queryChange(query) {
|
queryChange(query) {
|
||||||
this.queryPassed = new RegExp(query, 'i').test(this.currentLabel);
|
// query 里如果有正则中的特殊字符,需要先将这些字符转义
|
||||||
if (!this.queryPassed) {
|
let parsedQuery = query.replace(/(\^|\(|\)|\[|\]|\$|\*|\+|\.|\?|\\|\{|\}|\|)/g, '\\$1');
|
||||||
|
this.visible = new RegExp(parsedQuery, 'i').test(this.currentLabel);
|
||||||
|
if (!this.visible) {
|
||||||
this.parent.filteredOptionsCount--;
|
this.parent.filteredOptionsCount--;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -444,7 +444,7 @@
|
||||||
this.resetScrollTop();
|
this.resetScrollTop();
|
||||||
if (this.options[this.hoverIndex].disabled === true ||
|
if (this.options[this.hoverIndex].disabled === true ||
|
||||||
this.options[this.hoverIndex].groupDisabled === true ||
|
this.options[this.hoverIndex].groupDisabled === true ||
|
||||||
!this.options[this.hoverIndex].queryPassed) {
|
!this.options[this.hoverIndex].visible) {
|
||||||
this.navigateOptions('next');
|
this.navigateOptions('next');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@
|
||||||
this.resetScrollTop();
|
this.resetScrollTop();
|
||||||
if (this.options[this.hoverIndex].disabled === true ||
|
if (this.options[this.hoverIndex].disabled === true ||
|
||||||
this.options[this.hoverIndex].groupDisabled === true ||
|
this.options[this.hoverIndex].groupDisabled === true ||
|
||||||
!this.options[this.hoverIndex].queryPassed) {
|
!this.options[this.hoverIndex].visible) {
|
||||||
this.navigateOptions('prev');
|
this.navigateOptions('prev');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue