Commit e64ba965 authored by Leopoldthecoder's avatar Leopoldthecoder Committed by 杨奕

Select: fix default-first-option on created options

parent b027f69e
......@@ -691,16 +691,26 @@
checkDefaultFirstOption() {
this.hoverIndex = -1;
// highlight the created option
let hasCreated = false;
for (let i = this.options.length - 1; i >= 0; i--) {
if (this.options[i].created) {
hasCreated = true;
this.hoverIndex = i;
break;
}
}
if (hasCreated) return;
for (let i = 0; i !== this.options.length; ++i) {
const option = this.options[i];
if (this.query) {
// pick first options that passes the filter
// highlight first options that passes the filter
if (!option.disabled && !option.groupDisabled && option.visible) {
this.hoverIndex = i;
break;
}
} else {
// pick currently selected option
// highlight currently selected option
if (option.itemSelected) {
this.hoverIndex = i;
break;
......
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