Commit 01f85b18 authored by wacky6.AriesMBP's avatar wacky6.AriesMBP Committed by 杨奕

Select: fix dropdown scroll for multiple select

parent bd395fa1
...@@ -354,15 +354,17 @@ ...@@ -354,15 +354,17 @@
} }
}, },
scrollToOption(className = 'selected') { scrollToOption(option) {
if (this.$refs.popper) { if (this.$refs.popper && option) {
const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap'); const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
scrollIntoView(menu, menu.getElementsByClassName(className)[0]); scrollIntoView(menu, option.$el);
} }
}, },
handleMenuEnter() { handleMenuEnter() {
this.$nextTick(() => this.scrollToOption()); if (!this.multiple) {
this.$nextTick(() => this.scrollToOption(this.selected));
}
}, },
getOption(value) { getOption(value) {
...@@ -526,7 +528,7 @@ ...@@ -526,7 +528,7 @@
this.$emit('input', option.value); this.$emit('input', option.value);
this.visible = false; this.visible = false;
} }
this.$nextTick(() => this.scrollToOption()); this.$nextTick(() => this.scrollToOption(option));
}, },
getValueIndex(arr = [], value) { getValueIndex(arr = [], value) {
...@@ -588,7 +590,7 @@ ...@@ -588,7 +590,7 @@
} }
} }
} }
this.$nextTick(() => this.scrollToOption('hover')); this.$nextTick(() => this.scrollToOption(this.options[this.hoverIndex]));
}, },
selectOption() { selectOption() {
......
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