Closed oliviertassinari closed 1 year ago
I fully agree with the idea of shortcuts
I am just not sure about the boolean version
Here a three apis I can think of to define the default and custom shortcuts The prop naming is of course subject to changes.
// Option A: `true` for default and object for custom
// Very concise but very magic
import { DateRangePicker } from '@mui/x-date-pickers-pro'
<DateRangePicker {...other} rangeShortcuts /> // default
<DateRangePicker {...other} rangeShortcuts={[{ /** **/ }]} /> // custom
// Option B: always use objects
import { DateRangePicker, DEFAULT_RANGE_SHORTCUTS } from '@mui/x-date-pickers-pro'
<DateRangePicker {...other} rangeShortcuts={DEFAULT_RANGE_SHORTCUTS} /> // default
<DateRangePicker {...other} rangeShortcuts={[{ /** **/ }]} /> // custom
// Option C: decouple the feature activation and the feature config
// Similar to what we do for the `filterable` and `filterOperators` on the grid
import { DateRangePicker } from '@mui/x-date-pickers-pro'
<DateRangePicker {...other} enableShortcuts /> // default
<DateRangePicker {...other} enableShortcuts rangeShortcuts=[{ /** **/ }]} /> // custom
I guess the 1st one is great if we think most users will stick with the default one and custom shortcuts is an edge case. But if we think a large portion of our user will remove some shortcut / add others / change the behavior of others, then I prefer to be explicit and avoid props with two signatures.
Hi, actually it is possible to do it with the existing components with lot of work but it would be very interesting to add it by default 💯
@RayaneSlimani can you share snippets or reference code how you achieve this shortcuts in range picker?
@yaminagile just some logic and https://date-fns.org/ 😄 The shorcuts buttons are functions that return the date according to the selected shorcut.
What is the current state of this?
We did not start working on it
Hi, actually it is possible to do it with the existing components with lot of work but it would be very interesting to add it by default 💯
Did the same thing so i don't see a point in that. perhaps just a demo in documentation for it to get started faster?
Here a demo of a good example https://codesandbox.io/s/textfieldhiddenlabel-material-demo-forked-bpm46e?file=/RangePicker.tsx
There seems to be an error in the demo. When I click the Apply
I just get the error: onChange is not a function
. Do you know any solution to this please?
This feature is now somewhat more easier to implement using the newly introduced PaperContent
slot.
The examples include working demos with range shortcuts, with a caveat that onChange
is not triggered, because we are changing the range values externally.
What about using chips for shortcuts? Perhaps this might be easier to stack vertically in mobile as well.
As a replacement of the ActionBar
(the clear button) it would be nice
Just made a codesandbox to explore the different options developers can already set https://codesandbox.io/s/late-dew-zixos5?file=/demo.tsx
As discussed, below are a few variations with the action bar. When it comes to multiple chips, it seems that Material Design 2 and Material Design 3 both favor a horizontal scroll with a fade.
I have updated the benchmark of the issue (first comment) to polish it. Thoughts on https://github.com/mui/mui-x/issues/4563#issuecomment-1258712294:
It's what the account we have in https://sell.buysellads.com/ use. I feel that the value we use in the above test are shorter compared to how they might be used in real life by Product Manager/Product Designer. So, I think that it could be great to test longer labels too.
Thanks for the feedback! These options are definitely with a slightly different use case in mind than where I started. I added more options to figma that show how the chips can be used with this text and how it can be placed in different positions.
with a screenshot preview:
One note that if it gets to be an overwhelming amount of options, then perhaps they no longer qualify as "shortcuts" and would be better served as an input field with selections (like in the Google search console example).
like in the Google search console example
@gerdadesign This touch on something interesting! I think that we need to consider the notion of what happens when an end-user selects a preset. Does she/he select a start and end date or select the preset itself? (e.g., if you come 15 days later, what do you see?)
In practice, I think that we should optimize here for what's simpler for internal tools/the simple use cases. Based on the above benchmark, I would expect advanced external user-facing applications to implement the range feature themselves.
Here is my proposal for a default + the available customizations.
Default (inline) | bottom (full-width) | top | left | right |
---|---|---|---|---|
And here is a basic prototype of the suggested interaction. All shortcuts would be relative to today's date.
What's the ETA on this one? I love MUI, but it's a bit disappointing that something like this isn't provided in a paid solution when it's available for free in other libraries.
@abury This feature is currently blocked by #6900. From the different design approaches, we concluded that there is not a single obvious place for shortcuts. So we decided to implement first a solution to simplify the modification of the layout, and then add the shortcut block in the new layout. It should start in few weeks
@gerdadesign Great, thanks for the update. I think that it can make sense for Material Design.
If we move forward with this default look. I think that it will be important to have a customization demo the looks like how Google solves the problem on Google Ads and Google Analytics. I think that we could expect many designers or PMs to also ask their engineers to implement this approach.
@danilo-leal did you had initial thoughts on how the date picker should look like with Joy UI?
@oliviertassinari I don't have any specific designs for Joy UI as of now but, at least from an interaction standpoint, I do not expect it to be different from the one @gerdadesign is iterating on for Material UI. Of course, visually it will be something else but it would work similarly?!
@alexfauquette Thanks for the update, really looking forward to seeing it in action.
I think that we need to consider the notion of what happens when an end-user selects a preset. Does she/he select a start and end date or select the preset itself? (e.g., if you come 15 days later, what do you see?)
I have found a component that takes the latter approach: "selecting the preset" rather than the date range: https://vercel.com/design/calendar#presets
Should we address the way we handle the Reset
button?
Right now it's being treated the same as a chip, but it's functioning a little bit differently. MD3 adds a left-aligned Clear
button in the bottom action row. This could be used to clear both the range shortcuts as well as the selection even if they did not use the shortcuts.
I think that we need to consider the notion of what happens when an end-user selects a preset. Does she/he select a start and end date or select the preset itself? (e.g., if you come 15 days later, what do you see?)
I have found a component that takes the latter approach: "selecting the preset" rather than the date range: https://vercel.com/design/calendar#presets
Is there any intention of implementing this feature or is there a way to modify the date range picker locally to support this? The API I am working with works with keywords rather than dates and using Custom Actions isn't my favorite way of implementing this.
Is there any intention of implementing this feature or is there a way to modify the date range picker locally to support this?
We are not dismissing such idea, but we are currently spread a bit too thin to tackle such feature additions. 😉
@LukasTy now that we are passing the shortcut object to onChange
, people can do nice things in user-land
I did a quick POC here, but we could probably add a doc example based on this approach.
If people wants to entirely disable the view part in favor of a preset list, then I'd suggest using this doc section as the main inspiration.
Referring to https://github.com/mui-org/material-ui-pickers/issues/1293#issuecomment-538374383, I think that it would very valuable to implement a range shortcut feature. I was proposing this API:
but I have no doubt other, potentially better, alternative APIs are possible.
Requests
Benchmarks
For the benchmark, we can consider: