From 37ee8e9f88ff504a858672fef0cca6649aead171 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Tue, 17 Jan 2017 16:25:47 +0800 Subject: [PATCH 1/2] Select: update style if initially invisible --- packages/select/src/select.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index a1dc7e02..35d923f3 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -606,6 +606,11 @@ resetInputWidth() { this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width; + }, + + handleResize() { + this.resetInputWidth(); + if (this.multiple) this.resetInputHeight(); } }, @@ -632,7 +637,7 @@ if (this.multiple && Array.isArray(this.value) && this.value.length > 0) { this.currentPlaceholder = ''; } - addResizeListener(this.$el, this.resetInputWidth); + addResizeListener(this.$el, this.handleResize); if (this.remote && this.multiple) { this.resetInputHeight(); } @@ -644,7 +649,7 @@ }, destroyed() { - if (this.resetInputWidth) removeResizeListener(this.$el, this.resetInputWidth); + if (this.handleResize) removeResizeListener(this.$el, this.handleResize); } }; From b5d5922709436bf04141846ea3a0dca5e9196422 Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Wed, 18 Jan 2017 14:40:42 +0800 Subject: [PATCH 2/2] Select: get the latest cached option --- packages/select/src/select.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index 35d923f3..e423e8c5 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -363,7 +363,13 @@ }, getOption(value) { - const option = this.cachedOptions.filter(option => option.value === value)[0]; + let option; + for (let i = 0, len = this.cachedOptions.length; i < len; i++) { + const cachedOption = this.cachedOptions[i]; + if (cachedOption.value === value) { + option = cachedOption; + } + } if (option) return option; const label = typeof value === 'string' || typeof value === 'number' ? value : '';