Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 disableDate 传入 lambda 函数被频繁触发问题 #1569

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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