TimeSelect: fix resetField not working when user inputs an invalid value (#10176)

pull/10181/head
Harlan 2018-03-15 11:54:02 +08:00 committed by 杨奕
parent c48a69c947
commit b24a9ce729
3 changed files with 17 additions and 1 deletions

View File

@ -502,6 +502,8 @@ export default {
gpuAcceleration: false gpuAcceleration: false
}; };
this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left; this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
this.$on('fieldReset', this.handleFieldReset);
}, },
methods: { methods: {
@ -634,6 +636,10 @@ export default {
this.pickerVisible = false; this.pickerVisible = false;
}, },
handleFieldReset(initialValue) {
this.userInput = initialValue;
},
handleFocus() { handleFocus() {
const type = this.type; const type = this.type;

View File

@ -6,8 +6,16 @@ export default {
name: 'ElTimeSelect', name: 'ElTimeSelect',
componentName: 'ElTimeSelect',
props: {
type: {
type: String,
default: 'time-select'
}
},
beforeCreate() { beforeCreate() {
this.type = 'time-select';
this.panel = Panel; this.panel = Panel;
} }
}; };

View File

@ -227,6 +227,8 @@
这里需要强行触发一次刷新 validateDisabled 的值 这里需要强行触发一次刷新 validateDisabled 的值
确保 Select 下一次值改变时能正确触发校验 */ 确保 Select 下一次值改变时能正确触发校验 */
this.broadcast('ElSelect', 'fieldReset'); this.broadcast('ElSelect', 'fieldReset');
this.broadcast('ElTimeSelect', 'fieldReset', this.initialValue);
}, },
getRules() { getRules() {
let formRules = this.form.rules; let formRules = this.form.rules;