-
-
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] Datepicker prop view doesn't controll the visible view #13546
Comments
Hello @Svobi95, thank you for opening this issue! 🙏 The culprit of the problem seems to be here:
The same behavior works without problems on The following diff seems to solve the problem: diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerViews.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerViews.ts
index 4ed9a1a87..e96e3754f 100644
--- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerViews.ts
+++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerViews.ts
@@ -183,12 +183,12 @@ export const usePickerViews = <
TAdditionalProps
>): UsePickerViewsResponse<TView> => {
const { onChange, open, onClose } = propsFromPickerValue;
- const { views, openTo, onViewChange, viewRenderers, timezone } = props;
+ const { view: inView, views, openTo, onViewChange, viewRenderers, timezone } = props;
const { className, sx, ...propsToForwardToView } = props;
const { view, setView, defaultView, focusedView, setFocusedView, setValueAndGoToNextView } =
useViews({
- view: undefined,
+ view: inView,
views,
openTo,
onChange, Running tests after this change does not produce any failures. 🤔 🤷 @Svobi95 an additional note is that your usage of toolbar slot might result in problems even if the issue was fixed. |
I must admit that I don't remember, and that your fix seems to make a lot of sense... |
@Svobi95: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/jovial-pond-2jx5kf?file=%2Fsrc%2FDemo.tsx%3A15%2C31
Steps:
month
Current behavior
The Datepicker view is not changed to
month
Expected behavior
The Datepicker view should change to
month
Context
We want to have control over the visible view, which should be possible according to the documentation through the
view
prop.Your environment
npx @mui/envinfo
Search keywords: datepicker, view
Search keywords:
The text was updated successfully, but these errors were encountered: