Skip to content

Commit

Permalink
Merge pull request ElemeFE#2466 from Leopoldthecoder/select-style
Browse files Browse the repository at this point in the history
Select: update style if initially invisible
  • Loading branch information
baiyaaaaa authored Jan 18, 2017
2 parents b137274 + b5d5922 commit 6555725
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/select/src/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '';
Expand Down Expand Up @@ -606,6 +612,11 @@
resetInputWidth() {
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
},
handleResize() {
this.resetInputWidth();
if (this.multiple) this.resetInputHeight();
}
},
Expand All @@ -632,7 +643,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();
}
Expand All @@ -644,7 +655,7 @@
},
destroyed() {
if (this.resetInputWidth) removeResizeListener(this.$el, this.resetInputWidth);
if (this.handleResize) removeResizeListener(this.$el, this.handleResize);
}
};
</script>

0 comments on commit 6555725

Please sign in to comment.