Commit 55fd2de6 authored by 杨南鸿's avatar 杨南鸿

处理输入框首次校验问题

parent 7791ddb8
...@@ -138,9 +138,7 @@ ...@@ -138,9 +138,7 @@
hovering: false, hovering: false,
focused: false, focused: false,
isComposing: false, isComposing: false,
passwordVisible: false, passwordVisible: false
focusTimer: null,
focusOpen: false
}; };
}, },
...@@ -191,6 +189,10 @@ ...@@ -191,6 +189,10 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
lazy: {
type: [Boolean, Object],
default: false
},
tabindex: String tabindex: String
}, },
...@@ -305,6 +307,9 @@ ...@@ -305,6 +307,9 @@
}; };
}, },
handleBlur(event) { handleBlur(event) {
if (this.lazy) {
this.handleInput(event, true);
}
this.focused = false; this.focused = false;
this.$emit('blur', event); this.$emit('blur', event);
if (this.validateEvent) { if (this.validateEvent) {
...@@ -356,22 +361,20 @@ ...@@ -356,22 +361,20 @@
this.handleInput(event); this.handleInput(event);
} }
}, },
handleInput(event) { handleInput(event, refresh) {
// should not emit input during composition // should not emit input during composition
// see: https://github.com/ElemeFE/element/issues/10516 // see: https://github.com/ElemeFE/element/issues/10516
if (this.isComposing) return; if (this.isComposing || (this.lazy && !refresh)) return;
// hack for https://github.com/ElemeFE/element/issues/8548 // hack for https://github.com/ElemeFE/element/issues/8548
// should remove the following line when we don't support IE // should remove the following line when we don't support IE
if (event.target.value === this.nativeInputValue) return; if (event.target.value === this.nativeInputValue) return;
clearTimeout(this.focusTimer); this.$emit('input', event.target.value);
this.focusTimer = setTimeout(() => {
this.$emit('input', event.target.value); // ensure native input value is controlled
// ensure native input value is controlled // see: https://github.com/ElemeFE/element/issues/12850
// see: https://github.com/ElemeFE/element/issues/12850 this.$nextTick(this.setNativeInputValue);
this.$nextTick(this.setNativeInputValue);
}, 300);
}, },
handleChange(event) { handleChange(event) {
this.$emit('change', event.target.value); this.$emit('change', event.target.value);
......
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