fix(select): handle blur incorrectly so value will not change

This commit is contained in:
07akioni 2019-08-22 17:19:44 +08:00
parent b805631408
commit ea70669c2a
2 changed files with 9 additions and 8 deletions

View File

@ -93,7 +93,6 @@
:readonly="!disabled && filterable ? false : 'readonly'" :readonly="!disabled && filterable ? false : 'readonly'"
@input="handleSingleInputInput" @input="handleSingleInputInput"
@focus="handleSingleInputFocus" @focus="handleSingleInputFocus"
@blur="handleSingleInputBlur"
> >
</div> </div>
</div> </div>
@ -373,6 +372,10 @@ export default {
handleClickOutsideMenu (e) { handleClickOutsideMenu (e) {
if (!this.$refs.activator.contains(e.target) && !this.scrolling) { if (!this.$refs.activator.contains(e.target) && !this.scrolling) {
this.deactivate() this.deactivate()
if (this.filterable && !this.multiple) {
this.pattern = ''
this.singleInputActive = false
}
} }
}, },
closeMenu () { closeMenu () {
@ -427,6 +430,10 @@ export default {
this.$emit('input', newValue) this.$emit('input', newValue)
this.emitChangeEvent(newValue) this.emitChangeEvent(newValue)
} else { } else {
if (this.filterable && !this.multiple) {
this.pattern = ''
this.singleInputActive = false
}
this.$emit('input', option.value) this.$emit('input', option.value)
this.emitChangeEvent(option.value) this.emitChangeEvent(option.value)
this.closeMenu() this.closeMenu()
@ -520,13 +527,6 @@ export default {
this.singleInputActive = true this.singleInputActive = true
} }
}, },
handleSingleInputBlur () {
// console.log('handleSingleInputBlur')
if (this.filterable && !this.multiple) {
this.pattern = ''
this.singleInputActive = false
}
},
handleSingleInputInput (e) { handleSingleInputInput (e) {
this.pattern = e.target.value this.pattern = e.target.value
if (this.onSearch) { if (this.onSearch) {

View File

@ -203,6 +203,7 @@ export default {
if (selectElement) { if (selectElement) {
selectElement.focus() selectElement.focus()
} }
console.log('handleOptionClick', option)
this.toggleOption(option) this.toggleOption(option)
}, },
handleMenuMouseLeave () { handleMenuMouseLeave () {