-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[pickers] Allow specifying the current year in <MonthCalendar />
#8852
Comments
This issue is similar to #8837 The MonthCalendar would need a new prop similar to --- a/packages/x-date-pickers/src/MonthCalendar/MonthCalendar.tsx
+++ b/packages/x-date-pickers/src/MonthCalendar/MonthCalendar.tsx
@@ -77,6 +77,7 @@ export const MonthCalendar = React.forwardRef(function MonthCalendar<TDate>(
const {
className,
value: valueProp,
+ currentMonth,
defaultValue,
disabled,
disableFuture,
@@ -108,8 +109,8 @@ export const MonthCalendar = React.forwardRef(function MonthCalendar<TDate>(
const todayMonth = React.useMemo(() => utils.getMonth(now), [utils, now]);
const selectedDateOrStartOfMonth = React.useMemo(
- () => value ?? utils.startOfMonth(now),
- [now, utils, value],
+ () => value ?? currentMonth ?? utils.startOfMonth(now),
+ [now, currentMonth, utils, value],
);
const selectedMonth = React.useMemo(() => { |
<MonthCalendar />
|
If I'm understanding correctly, |
The <DateCalendar views={["year", "month"]} /> https://codesandbox.io/s/wonderful-boyd-yu9qse?file=/demo.tsx |
As @alexfauquette said:
|
Duplicates
Latest version
Summary 💡
Is there some way to change the year on the
MonthCalendar
? Without it the component is pretty unusable without extra effort to build a year picker around it. Or maybe I'm unclear on how the component is intended to be used -- could someone provide an example?Examples 🌈
No response
Motivation 🔦
I'm attempting to build a custom modal date range picker around MUI components, but I can't use the
MonthPicker
without a way to adjust the year on it.Order ID 💳 (optional)
46840
The text was updated successfully, but these errors were encountered: