-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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] Clean view management #8989
Comments
Not sure to understand. isn't the For me, the current API is a legacy of the v5. At that time, you could not create custom views, and the workflow was a succession of views. We broke this behavior multiple times:
My proposal is to remove the link between
The DX could look something like that: import DatePicker from '@mui/x-date-pickers/DatePicker'
import { yearView, dayView } from '@mui/x-date-pickers'
<DatePicker
views={[yearView, dayView]}
openTo='year'
/> with Which would allows users to do Maybe it's introducing too much complexity for most users compared to the number of users willing to have that deep customization. By the way, it's still possible to keep |
My proposal is to totally decorrelate the two concepts, so no.
That's the question I raise at the end of my message. If we go for something similar to what you are proposing, then I would indeed be in favor of supporting the string version, I don't think we should bother people with renderers for basic use cases. I see 3 downsides with your solution:
|
We don't. If there is an unknown view, we can just fall back on the default format. If the user is advanced enough to creat its own view, they can probably set the format that want
The only difference with string +import { hourClock, minuteClock } from '@mui/x-date-pickers
<DateTimePicker
- views=['hour', 'minute', 'day']
+ views=[hourClock, minuteClock, 'day']
/>
|
But it means that we can't use those "meta" views for our buit-in views.
So you would keep the
In which case we go back to my point 1. => we can no longer have the smart format with the time (which we don't use right now on this component to be fair). |
Moreover, concerning the order of the views, if we say My feeling is that, if the UI is no longer 1 view = 1 screen, it requires more and more hacks to make reconciliate the |
Honestly, I struggle to find a good and simple mental model to raise this inconsistency. |
IMHO, we are still not sure about the right direction to take on this topic.
On the contrary, we still have not documented anything about |
Current behavior
We have 5 props:
views
to define the views used inside the componentsopenTo
to define the view to render when opening the componentview
to control the current viewonViewChange
to update the current viewviewRenderers
to change how each view is renderedProblem
Our main problem is that the term "views" is used to define 2 different concepts that were equivalent but that not anymore.
1. Configure the pieces of date-time the user can select
Example with
TimePicker
If a user does the following customization:
Then he wants to allow editing the
seconds
, which are not included in theTimePicker
by default.Example with
DatePicker
If a user does the following customization:
Then he wants to disable the editing of the
day
and add the editing of themonth
.2. Configure the flow of picking a value
Example with
DatePicker
If a user does the following customization:
Then he wants every user to pass through the
year
view (which is not part of the default flow; you must click on the header to access it).Example with
TimePicker
If a user does the following customization:
Then he wants to change the UI of all the time views to use the
TimeClock
component even on desktop.Proposals
Proposal A: Use a
sections
prop to define the date-time parts to editOn one hand, we would have the
sections
which would be used to define the part of the date-time user can select.FieldSectionType
intoPickersSectionType
sections
of typePickersSectionType
The examples above about the 1st concept would become:
On the other hand, we would have the views, which would be used to define the steps used to select a value.
The pickers would have only one view, which would handle its internal screens if several (like currently in the
DateCalendar
).It would be impossible to change the order of the views, but I honestly struggle to find a real use case for this feature.
The
MobileDateTimePicker
would need a new renderer that rendersTimeClock
andDateCalendar
alternatively.The
DesktopDateTimePicker
would need a new renderer that renders bothDigitalClock
andDateCalendar
(but @LukasTy needs it anyway).The other pickers would keep their current renderers.
People could update their renderer like today but without duplicates
Problems
How to force field-editing on some sections
We could say that if at any point a renderer returns
null
, then we fallback to field editing.How to allow the user to open the
DateCalendar
on theyear
view or even to control the view inside the renderer?We could move the
view
/openTo
/onVIewChange
logic as props ofDateCalendar
only and pass them through props. This one is very unclear to me.The text was updated successfully, but these errors were encountered: