Skip to content

Commit

Permalink
fix: 修复 datepicker 输入框变化面板未响应问题 (Tencent#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
honkinglin authored and sinbadmaster committed Jun 2, 2023
1 parent 2095f57 commit bcc6b0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/date-picker/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export default defineComponent({
const nextMonth = [...month.value];
nextMonth[partialIndex] = nextVal;
// 保证左侧时间不大于右侧
if (year[0] === year[1]) {
if (year.value[0] === year.value[1]) {
if (partialIndex === 0) nextMonth[1] = Math.max(nextMonth[0], nextMonth[1]);
if (partialIndex === 1) nextMonth[0] = Math.min(nextMonth[0], nextMonth[1]);
}
Expand Down
1 change: 1 addition & 0 deletions src/date-picker/hooks/useRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function useRange(props: TdDateRangePickerProps) {

// 跳过不符合格式化的输入框内容
if (!isValidDate(newVal, formatRef.value.format)) return;
cacheValue.value = newVal;
const newYear: Array<number> = [];
const newMonth: Array<number> = [];
const newTime: Array<string> = [];
Expand Down
5 changes: 3 additions & 2 deletions src/date-picker/hooks/useSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ export default function useSingle(props: TdDatePickerProps) {

// 跳过不符合格式化的输入框内容
if (!isValidDate(val, formatRef.value.format)) return;
const newMonth = dayjs(val).month();
const newYear = dayjs(val).year();
cacheValue.value = val;
const newMonth = parseToDayjs(val, formatRef.value.format).month();
const newYear = parseToDayjs(val, formatRef.value.format).year();
const newTime = formatTime(val, formatRef.value.timeFormat);
!Number.isNaN(newYear) && (year.value = newYear);
!Number.isNaN(newMonth) && (month.value = newMonth);
Expand Down

0 comments on commit bcc6b0d

Please sign in to comment.