Commit 0ccd537c authored by 杨奕's avatar 杨奕 Committed by baiyaaaaa

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

parent 15dc895e
<template> <template>
<ul class="el-select-group__wrap"> <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> <li>
<ul class="el-select-group"> <ul class="el-select-group">
<slot></slot> <slot></slot>
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
name: 'el-option-group', name: 'el-option-group',
componentName: 'ElOptionGroup',
props: { props: {
label: String, label: String,
disabled: { disabled: {
...@@ -25,12 +27,30 @@ ...@@ -25,12 +27,30 @@
} }
}, },
data() {
return {
visible: true
};
},
watch: { watch: {
disabled(val) { disabled(val) {
this.broadcast('ElOption', 'handleGroupDisabled', 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() { mounted() {
if (this.disabled) { if (this.disabled) {
this.broadcast('ElOption', 'handleGroupDisabled', this.disabled); this.broadcast('ElOption', 'handleGroupDisabled', this.disabled);
......
...@@ -228,9 +228,11 @@ ...@@ -228,9 +228,11 @@
this.broadcast('ElOption', 'resetIndex'); this.broadcast('ElOption', 'resetIndex');
} else if (typeof this.filterMethod === 'function') { } else if (typeof this.filterMethod === 'function') {
this.filterMethod(val); this.filterMethod(val);
this.broadcast('ElOptionGroup', 'queryChange');
} else { } else {
this.filteredOptionsCount = this.optionsCount; this.filteredOptionsCount = this.optionsCount;
this.broadcast('ElOption', 'queryChange', val); this.broadcast('ElOption', 'queryChange', val);
this.broadcast('ElOptionGroup', 'queryChange');
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment