mirror of https://github.com/ElemeFE/element
Select: remove blur emit after soft focus (#10822)
parent
1d33bae558
commit
9c058fbf7c
|
@ -124,7 +124,7 @@
|
||||||
|
|
||||||
selectOptionClick() {
|
selectOptionClick() {
|
||||||
if (this.disabled !== true && this.groupDisabled !== true) {
|
if (this.disabled !== true && this.groupDisabled !== true) {
|
||||||
this.dispatch('ElSelect', 'handleOptionClick', this);
|
this.dispatch('ElSelect', 'handleOptionClick', [this, true]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
:auto-complete="autoComplete"
|
:auto-complete="autoComplete"
|
||||||
:size="selectSize"
|
:size="selectSize"
|
||||||
:disabled="selectDisabled"
|
:disabled="selectDisabled"
|
||||||
:readonly="!filterable || multiple || !visible"
|
:readonly="!filterable || multiple"
|
||||||
:validate-event="false"
|
:validate-event="false"
|
||||||
:class="{ 'is-focus': visible }"
|
:class="{ 'is-focus': visible }"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
|
@ -312,7 +312,8 @@
|
||||||
inputHovering: false,
|
inputHovering: false,
|
||||||
currentPlaceholder: '',
|
currentPlaceholder: '',
|
||||||
menuVisibleOnFocus: false,
|
menuVisibleOnFocus: false,
|
||||||
isOnComposition: false
|
isOnComposition: false,
|
||||||
|
isSilentBlur: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -565,7 +566,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
handleBlur(event) {
|
handleBlur(event) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.isSilentBlur) {
|
||||||
|
this.isSilentBlur = false;
|
||||||
|
} else {
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
this.softFocus = false;
|
this.softFocus = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -652,7 +659,7 @@
|
||||||
}, 300);
|
}, 300);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleOptionSelect(option) {
|
handleOptionSelect(option, byClick) {
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
const value = this.value.slice();
|
const value = this.value.slice();
|
||||||
const optionIndex = this.getValueIndex(value, option.value);
|
const optionIndex = this.getValueIndex(value, option.value);
|
||||||
|
@ -674,10 +681,11 @@
|
||||||
this.emitChange(option.value);
|
this.emitChange(option.value);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
}
|
}
|
||||||
this.$nextTick(() => {
|
this.isSilentBlur = byClick;
|
||||||
if (this.visible) return;
|
|
||||||
this.scrollToOption(option);
|
|
||||||
this.setSoftFocus();
|
this.setSoftFocus();
|
||||||
|
if (this.visible) return;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.scrollToOption(option);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -663,11 +663,11 @@ describe('Select', () => {
|
||||||
vm.$el.querySelector('input').focus();
|
vm.$el.querySelector('input').focus();
|
||||||
vm.$el.querySelector('input').blur();
|
vm.$el.querySelector('input').blur();
|
||||||
|
|
||||||
vm.$nextTick(_ => {
|
setTimeout(_ => {
|
||||||
expect(spyFocus.calledOnce).to.be.true;
|
expect(spyFocus.calledOnce).to.be.true;
|
||||||
expect(spyBlur.calledOnce).to.be.true;
|
expect(spyBlur.calledOnce).to.be.true;
|
||||||
done();
|
done();
|
||||||
});
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return focus to input inside select after option select', done => {
|
it('should return focus to input inside select after option select', done => {
|
||||||
|
|
Loading…
Reference in New Issue