Select: fix filterable group bug, fixed #1678 (#1679)

pull/1702/head
杨奕 2016-12-13 10:34:53 +08:00 committed by baiyaaaaa
parent 15dc895ee6
commit 0ccd537cc8
2 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<template>
<ul class="el-select-group__wrap">
<li class="el-select-group__title">{{ label }}</li>
<li class="el-select-group__title" v-show="visible">{{ label }}</li>
<li>
<ul class="el-select-group">
<slot></slot>
@ -17,6 +17,8 @@
name: 'el-option-group',
componentName: 'ElOptionGroup',
props: {
label: String,
disabled: {
@ -25,12 +27,30 @@
}
},
data() {
return {
visible: true
};
},
watch: {
disabled(val) {
this.broadcast('ElOption', 'handleGroupDisabled', val);
}
},
methods: {
queryChange() {
this.visible = this.$children &&
Array.isArray(this.$children) &&
this.$children.some(option => option.visible === true);
}
},
created() {
this.$on('queryChange', this.queryChange);
},
mounted() {
if (this.disabled) {
this.broadcast('ElOption', 'handleGroupDisabled', this.disabled);

View File

@ -228,9 +228,11 @@
this.broadcast('ElOption', 'resetIndex');
} else if (typeof this.filterMethod === 'function') {
this.filterMethod(val);
this.broadcast('ElOptionGroup', 'queryChange');
} else {
this.filteredOptionsCount = this.optionsCount;
this.broadcast('ElOption', 'queryChange', val);
this.broadcast('ElOptionGroup', 'queryChange');
}
},