From ba264fab0acef5683463367f802a9a2c45e07537 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Mon, 10 Oct 2016 14:42:01 +0800 Subject: [PATCH] fix Select automatically expand issue --- CHANGELOG.md | 1 + packages/select/src/option.vue | 2 +- packages/select/src/select.vue | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcc072ff..eaf2fdb79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - 新增 Input textarea 类型的 rows, autosize 属性 - 为 Tree 添加 getCheckedNodes 方法和 node-click、check-change 回调 - 新增 DatePicker 禁用日期功能 #253 +- 修复 多选可搜索的 Select 下拉选项自动展开的问题 #### 非兼容性更新 diff --git a/packages/select/src/option.vue b/packages/select/src/option.vue index 8c6f893f4..c138cc0cf 100644 --- a/packages/select/src/option.vue +++ b/packages/select/src/option.vue @@ -114,7 +114,7 @@ this.index = this.parent.options.indexOf(this); if (this.currentSelected === true) { - this.dispatch('select', 'addOptionToValue', this); + this.dispatch('select', 'addOptionToValue', [this, true]); } this.$on('queryChange', this.queryChange); diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index a97158fd3..5a29e759d 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -214,6 +214,11 @@ selected(val) { if (this.multiple) { + if (this.selected.length > 0) { + this.currentPlaceholder = ''; + } else { + this.currentPlaceholder = this.cachedPlaceHolder; + } if (this.selectedInit) { this.selectedInit = false; return; @@ -223,11 +228,6 @@ this.$emit('input', result); this.$emit('change', result); - if (this.selected.length > 0) { - this.currentPlaceholder = ''; - } else { - this.currentPlaceholder = this.cachedPlaceHolder; - } this.$nextTick(() => { this.resetInputHeight(); }); @@ -340,10 +340,10 @@ } }, - addOptionToValue(option) { + addOptionToValue(option, init) { if (this.multiple) { if (this.selected.indexOf(option) === -1 && (this.remote ? this.value.indexOf(option.value) === -1 : true)) { - this.selectedInit = false; + this.selectedInit = !!init; this.selected.push(option); this.resetHoverIndex(); }