Skip to content

Commit

Permalink
fix(timepicker): clear value reset current time
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Apr 12, 2022
1 parent d309b27 commit 1b5e8f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ export default mixins(
handleTInputFocus() {
// TODO: 待改成select-input后删除
// hack 在input聚焦时马上blur 避免出现输入光标
(this.$refs.native as HTMLInputElement).blur();
this.$nextTick(() => {
(this.$refs.native as HTMLInputElement).blur();
});
},
handleTimePick(col: EPickerCols, time: number, index: number) {
if (!this.range || index === 0) {
Expand Down
14 changes: 4 additions & 10 deletions src/time-picker/time-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,12 @@ export default mixins(getConfigReceiverMixins<TimePickerInstance, TimePickerConf
return [dayjs().hour(0).minute(0).second(0)];
},
textClassName(): string {
const isDefault = (this.inputTime as any).some(
(item: InputTime) => !!item.hour && !!item.minute && !!item.second,
);
const isDefault = !!this.inputTime.hour && !!this.inputTime.minute && !!this.inputTime.second;
return isDefault ? '' : `${name}__group-text`;
},
},

watch: {
// 监听选中时间变动
time: {
handler() {
this.output();
},
},
value: {
handler() {
this.time = this.value ? dayjs(this.value, this.format) : undefined;
Expand Down Expand Up @@ -306,7 +298,9 @@ export default mixins(getConfigReceiverMixins<TimePickerInstance, TimePickerConf
handleTInputFocus() {
// TODO: 待改成select-input后删除
// hack 在input聚焦时马上blur 避免出现输入光标
(this.$refs.tInput as HTMLInputElement).blur();
this.$nextTick(() => {
(this.$refs.tInput as HTMLInputElement).blur();
});
},
renderInput() {
const classes = [
Expand Down
4 changes: 3 additions & 1 deletion src/time-picker/time-range-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ export default mixins(getConfigReceiverMixins<TimePickerInstance, TimePickerConf
handleTInputFocus() {
// TODO: 待改成select-input后删除
// hack 在input聚焦时马上blur 避免出现输入光标
(this.$refs.tInput as HTMLInputElement).blur();
this.$nextTick(() => {
(this.$refs.tInput as HTMLInputElement).blur();
});
},
renderInput() {
const classes = [
Expand Down

0 comments on commit 1b5e8f2

Please sign in to comment.