|
@@ -12,7 +12,7 @@
|
|
|
<el-tag
|
|
|
v-for="item in selected"
|
|
|
:key="getValueKey(item)"
|
|
|
- closable
|
|
|
+ :closable="!disabled"
|
|
|
:hit="item.hitState"
|
|
|
type="primary"
|
|
|
@close="deleteTag($event, item)"
|
|
@@ -367,13 +367,16 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- scrollToOption(className = 'selected') {
|
|
|
- const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
|
|
|
- scrollIntoView(menu, menu.getElementsByClassName(className)[0]);
|
|
|
+ scrollToOption(option) {
|
|
|
+ const target = Array.isArray(option) && option[0] ? option[0].$el : option.$el;
|
|
|
+ if (this.$refs.popper && target) {
|
|
|
+ const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
|
|
|
+ scrollIntoView(menu, target);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
handleMenuEnter() {
|
|
|
- this.$nextTick(() => this.scrollToOption());
|
|
|
+ this.$nextTick(() => this.scrollToOption(this.selected));
|
|
|
},
|
|
|
|
|
|
emitChange(val) {
|
|
@@ -384,8 +387,7 @@
|
|
|
|
|
|
getOption(value) {
|
|
|
let option;
|
|
|
- const type = typeof value;
|
|
|
- const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
|
|
|
+ const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
|
|
|
for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
|
|
|
const cachedOption = this.cachedOptions[i];
|
|
|
const isEqual = isObject
|
|
@@ -551,12 +553,11 @@
|
|
|
this.emitChange(option.value);
|
|
|
this.visible = false;
|
|
|
}
|
|
|
- this.$nextTick(() => this.scrollToOption());
|
|
|
+ this.$nextTick(() => this.scrollToOption(option));
|
|
|
},
|
|
|
|
|
|
getValueIndex(arr = [], value) {
|
|
|
- const type = typeof value;
|
|
|
- const isObject = type !== 'string' && type !== 'number' && type !== 'boolean';
|
|
|
+ const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
|
|
|
if (!isObject) {
|
|
|
return arr.indexOf(value);
|
|
|
} else {
|
|
@@ -613,7 +614,7 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- this.$nextTick(() => this.scrollToOption('hover'));
|
|
|
+ this.$nextTick(() => this.scrollToOption(this.options[this.hoverIndex]));
|
|
|
},
|
|
|
|
|
|
selectOption() {
|