Skip to content

Commit

Permalink
fix: 修复 datepicker 传入 lambda 函数被频繁触发问题 (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
honkinglin committed Sep 27, 2022
1 parent 2b8b8b0 commit f9ca7cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/_common
20 changes: 10 additions & 10 deletions src/date-picker/panel/RangePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ export default defineComponent({
// 是否隐藏预选状态,只有 value 有值的时候需要隐藏
const hidePreselection = !props.panelPreselection && props.value.length === 2;

const disableDateOptions = computed(() => useDisableDate({
const disableDateOptions = useDisableDate({
format,
mode: props.mode,
disableDate: props.disableDate,
start:
props.isFirstValueSelected && props.activeIndex === 1
? new Date(parseToDayjs(props.value[0], format, 'start').toDate().setHours(0, 0, 0))
: undefined,
props.isFirstValueSelected && props.activeIndex === 1
? new Date(parseToDayjs(props.value[0], format, 'start').toDate().setHours(0, 0, 0))
: undefined,
end:
props.isFirstValueSelected && props.activeIndex === 0
? new Date(parseToDayjs(props.value[1], format).toDate().setHours(23, 59, 59))
: undefined,
}));
props.isFirstValueSelected && props.activeIndex === 0
? new Date(parseToDayjs(props.value[1], format).toDate().setHours(23, 59, 59))
: undefined,
});

const startTableData = computed(() => useTableData({
isRange: true,
Expand All @@ -91,7 +91,7 @@ export default defineComponent({
month: props.month[0],
mode: props.mode,
firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek,
...disableDateOptions.value,
...disableDateOptions,
}));

const endTableData = computed(() => useTableData({
Expand All @@ -110,7 +110,7 @@ export default defineComponent({
month: props.month[1],
mode: props.mode,
firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek,
...disableDateOptions.value,
...disableDateOptions,
}));

const panelContentProps = computed(() => ({
Expand Down
6 changes: 3 additions & 3 deletions src/date-picker/panel/SinglePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ export default defineComponent({
enableTimePicker: props.enableTimePicker,
});

const disableDateOptions = computed(() => useDisableDate({
const disableDateOptions = useDisableDate({
format,
mode: props.mode,
disableDate: props.disableDate,
}));
});

const tableData = computed(() => useTableData({
year: props.year,
month: props.month,
mode: props.mode,
start: props.value ? parseToDayjs(props.value, format).toDate() : undefined,
firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek,
...disableDateOptions.value,
...disableDateOptions,
}));

const panelContentProps = computed(() => ({
Expand Down

0 comments on commit f9ca7cc

Please sign in to comment.