Commit 9f345d89 authored by hetech's avatar hetech Committed by GitHub

Select: use initial height to reset height of input (#12719)

* Select: use initial height to reset height of input

* Update select.vue
parent faed4634
...@@ -152,12 +152,6 @@ ...@@ -152,12 +152,6 @@
import NavigationMixin from './navigation-mixin'; import NavigationMixin from './navigation-mixin';
import { isKorean } from 'element-ui/src/utils/shared'; import { isKorean } from 'element-ui/src/utils/shared';
const sizeMap = {
'medium': 36,
'small': 32,
'mini': 28
};
export default { export default {
mixins: [Emitter, Locale, Focus('reference'), NavigationMixin], mixins: [Emitter, Locale, Focus('reference'), NavigationMixin],
...@@ -319,6 +313,7 @@ ...@@ -319,6 +313,7 @@
selected: this.multiple ? [] : {}, selected: this.multiple ? [] : {},
inputLength: 20, inputLength: 20,
inputWidth: 0, inputWidth: 0,
initialInputHeight: 0,
cachedPlaceHolder: '', cachedPlaceHolder: '',
optionsCount: 0, optionsCount: 0,
filteredOptionsCount: 0, filteredOptionsCount: 0,
...@@ -655,7 +650,7 @@ ...@@ -655,7 +650,7 @@
let inputChildNodes = this.$refs.reference.$el.childNodes; let inputChildNodes = this.$refs.reference.$el.childNodes;
let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0]; let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0];
const tags = this.$refs.tags; const tags = this.$refs.tags;
const sizeInMap = sizeMap[this.selectSize] || 40; const sizeInMap = this.initialInputHeight || 40;
input.style.height = this.selected.length === 0 input.style.height = this.selected.length === 0
? sizeInMap + 'px' ? sizeInMap + 'px'
: Math.max( : Math.max(
...@@ -870,12 +865,17 @@ ...@@ -870,12 +865,17 @@
this.currentPlaceholder = ''; this.currentPlaceholder = '';
} }
addResizeListener(this.$el, this.handleResize); addResizeListener(this.$el, this.handleResize);
const reference = this.$refs.reference;
if (reference && reference.$el) {
this.initialInputHeight = reference.$el.getBoundingClientRect().height;
}
if (this.remote && this.multiple) { if (this.remote && this.multiple) {
this.resetInputHeight(); this.resetInputHeight();
} }
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.reference && this.$refs.reference.$el) { if (reference && reference.$el) {
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width; this.inputWidth = reference.$el.getBoundingClientRect().width;
} }
}); });
this.setSelected(); this.setSelected();
......
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