-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DateRangePicker] Implement range shortcuts #4563
Comments
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 // 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. |
@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/ 😄 |
What is the current state of this? |
We did not start working on it |
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 |
There seems to be an error in the demo. When I click the |
This feature is now somewhat more easier to implement using the newly introduced |
As a replacement of the Just made a codesandbox to explore the different options developers can already set |
As discussed, below are a few variations with the action bar. A few chips inline with action barMany chips inline with action bar, with horizontal scrollMany chips vertically stacked, container inline with action barMany chips and action bar vertically stacked (also showing outline style) |
I have updated the benchmark of the issue (first comment) to polish it. Thoughts on #4563 (comment):
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. 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). |
@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.
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 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 |
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. |
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 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 mui/material-ui-pickers#1293 (comment), 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:
The text was updated successfully, but these errors were encountered: