-
-
Notifications
You must be signed in to change notification settings - Fork 50.8k
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: Calendar validRange prevents disabledDate #25626
Changes from 4 commits
c128ad8
e17e5ec
d9123f2
c047f30
75aef2a
047a009
259f371
982d9ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,18 +122,15 @@ function generateCalendar<DateType>(generateConfig: GenerateConfig<DateType>) { | |
); | ||
|
||
// Disabled Date | ||
const mergedDisabledDate = React.useMemo(() => { | ||
if (validRange) { | ||
return (date: DateType) => { | ||
return ( | ||
generateConfig.isAfter(validRange[0], date) || | ||
const mergedDisabledDate = React.useCallback((date: DateType) => { | ||
const notInRange = validRange | ||
? generateConfig.isAfter(validRange[0], date) || | ||
generateConfig.isAfter(date, validRange[1]) | ||
); | ||
}; | ||
} | ||
|
||
return disabledDate; | ||
}, [disabledDate, validRange]); | ||
: false; | ||
return notInRange || !!disabledDate?.(date); | ||
}, | ||
[disabledDate, validRange], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你这个为啥会被格式化成这样,差点没看懂 😂😂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 提到外面来的话就直接用 useCallback 吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
); | ||
|
||
// ====================== Events ====================== | ||
const triggerPanelChange = (date: DateType, newMode: CalendarMode) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加个测试用例
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done