From f5ecd1677700cd2a0767ee60d9320f5625589a6f Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Fri, 13 Jan 2017 16:46:20 +0800 Subject: [PATCH] fixed #186 --- src/components/select/option-group.vue | 28 +++++++++++++++++++++++++--- test/routers/select.vue | 20 ++++++-------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/components/select/option-group.vue b/src/components/select/option-group.vue index b47f07e..ee5a3a2 100644 --- a/src/components/select/option-group.vue +++ b/src/components/select/option-group.vue @@ -1,8 +1,8 @@ @@ -18,8 +18,30 @@ }, data () { return { - prefixCls: prefixCls + prefixCls: prefixCls, + hidden: false // for search }; + }, + methods: { + queryChange () { + this.$nextTick(() => { + const options = this.$els.options.querySelectorAll('.ivu-select-item'); + let hasVisibleOption = false; + for (let i = 0; i < options.length; i++) { + if (options[i].style.display !== 'none') { + hasVisibleOption = true; + break; + } + } + this.hidden = !hasVisibleOption; + }); + } + }, + events: { + 'on-query-change' () { + this.queryChange(); + return true; + } } }; diff --git a/test/routers/select.vue b/test/routers/select.vue index fb250cd..baa8108 100644 --- a/test/routers/select.vue +++ b/test/routers/select.vue @@ -1,16 +1,9 @@