Skip to content
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] Add DigitalClock to DesktopDateTimePicker #8946

Merged
merged 31 commits into from
May 26, 2023

Conversation

LukasTy
Copy link
Member

@LukasTy LukasTy commented May 10, 2023

Fixes #8819

date-time-picker-ui

The design update syncing is pending and will be done after #8851 is merged.

  • Create dateTimeViewRenderer with two column layout
  • Use dateTimeViewRenderer for all views in DesktopDateTimePicker in case there are no custom viewRenderers provided
    • if there are any custom renderers, fallback to the original renderers, where only date views have entries to benefit from legacy layout
  • Use updated DateTimePickerToolbar styling in case the new dateTimeViewRenderers are used
  • Update doc and migration guide
  • Update tests to work after the changes
  • Extend existing tests with coverage for multiple views instead of testing only one preferred view
  • Manual tests
    • Test custom viewRenderers behaves as expected
    • Test new DesktopDateTimePicker props & slot behavior

@LukasTy LukasTy added component: pickers This is the name of the generic UI component, not the React module! component: DateTimePicker The React component. labels May 10, 2023
@LukasTy LukasTy self-assigned this May 10, 2023
@mui-bot
Copy link

mui-bot commented May 10, 2023

Netlify deploy preview

Netlify deploy preview: https://deploy-preview-8946--material-ui-x.netlify.app/

Updated pages

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 680.1 1,365.7 680.1 974.98 270.683
Sort 100k rows ms 835.3 1,447.6 1,447.6 1,138.6 214.503
Select 100k rows ms 227 391.1 312.6 301.34 58.468
Deselect 100k rows ms 153.5 440.4 196.1 241.78 102.356

Generated by 🚫 dangerJS against 142add2

@ArtHell
Copy link

ArtHell commented May 12, 2023

Will it be possible to hide digital clock? So that our users will be able to pick date from calendar and put time manually? As it is right now for DesktopDateTimePicker

@LukasTy
Copy link
Member Author

LukasTy commented May 15, 2023

Will it be possible to hide digital clock? So that our users will be able to pick date from calendar and put time manually? As it is right now for DesktopDateTimePicker

Yes, you'd get the current behavior back by reverting to the current configuration:

viewRenderers: {
  hours: null,
  minutes: null,
  seconds: null,
  meridiem: null // we'll see if it's possible to avoid the need of specifying this one
}

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 19, 2023
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

componentsProps: { toolbar: { hidden: true } },
}
: { slotProps: { toolbar: { hidden: true } } }),
slotProps: { toolbar: { hidden: true } },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cleaned some old 🗑️

@LukasTy LukasTy marked this pull request as ready for review May 19, 2023 15:29
@LukasTy LukasTy added the new feature New feature or request label May 19, 2023
Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a huge piece of works, congrats ! 🥳


const viewRenderers: PickerViewRendererLookup<TDate | null, DateOrTimeViewWithMeridiem, any, {}> =
// we can only ensure the expected two-column layout if none of the renderers are overridden
shouldUseNewRenderer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a way to at least drop this condition on v7
That's probably part of #8989, how can a renderer (here renderDesktopDateTimeView when used on a date view) be aware of which other views are using it.
In other words, how could renderDesktopDateTimeView adapt when used only for date views, if someone wants to use the TimeClock.

Or do we just say that in v7 people will have to also override the date views to set the renderDateView renderer.

skipDisabled,
timeViewsCount,
}: DateTimeViewRendererProps<TDate>) => {
const isActionBarVisible = !!resolveComponentProps(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK that's super not sexy...
But not sure how to do better

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. 🙈
But given layout, I didn't see other options of how to cleanly avoid having the unwanted divider/border when no actions are present. 🤷

Copy link
Member

@joserodolfofreitas joserodolfofreitas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the hard work integrating the digital clock on the pickers, @LukasTy!

A couple of notes:

  • I noticed when you select the last items on the list, they won't scroll to the top. Is this a technical limitation particular to the DateTime? (It's working on the TimePicker)
image
  • Auto-close on Meridiem:
    Selecting a Meridiem should not always close the view.
    I wonder what we can do here to get a proper auto-closing strategy that considers the selection of the other sections of the date.

  • Discrepancy between field and view
    I noticed that if you add "seconds" to the views property, it displays correctly, but perhaps we should consider reflecting this automatically on the field as well; unless the user provides a specific format.

image

@flaviendelangle
Copy link
Member

I noticed that if you add "seconds" to the views property, it displays correctly, but perhaps we should consider reflecting this automatically on the field as well; unless the user provides a specific format.

Right now, the "smart format" is only something applied on the DatePicker
I do agree that the TimePicker and DateTimePicker could also benefit from it.

But note, that if people do strange formats, the UI will not follow the order of the sections present on the format.
To do so, we would need to use the actual parsed format from the fields to build the UI, but I doubt the complexity is worth it.

@LukasTy
Copy link
Member Author

LukasTy commented May 24, 2023

Thank you for the feedback @joserodolfofreitas

I noticed when you select the last items on the list, they won't scroll to the top. Is this a technical limitation particular to the DateTime? (It's working on the TimePicker)

Indeed, that is an issue of a naive implementation on the MultiSectionDigitalClock side, which worked fine with a known height but needs to be adjusted to account for the fact that it will be taller in this case. 👌

Auto-close on Meridiem:
Selecting a Meridiem should not always close the view.
I wonder what we can do here to get a proper auto-closing strategy that considers the selection of the other sections of the date.

Well, it's the same logic that we have for the TimePicker, in this case, it's probably a little bit more obvious.
We do close the picker if it's the last view that has been chosen.
How would you change it? Close it only in case when a previous view was not a date view—at least one time section has already been chosen or at least focused/active.
But that would raise another problem—what would happen if you chose meridiem in such a case? Where would the focus jump? To the first time view? 🤔

Discrepancy between field and view
I noticed that if you add "seconds" to the views property, it displays correctly, but perhaps we should consider reflecting this automatically on the field as well; unless the user provides a specific format.

I believe that we've cleared this point during a meeting and confirmed that it is a separate issue that will be tacked via a separate PR. 👌

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 25, 2023
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 26, 2023
@LukasTy
Copy link
Member Author

LukasTy commented May 26, 2023

I noticed when you select the last items on the list, they won't scroll to the top. Is this a technical limitation particular to the DateTime? (It's working on the TimePicker)

Indeed, that is an issue of a naive implementation on the MultiSectionDigitalClock side, which worked fine with a known height but needs to be adjusted to account for the fact that it will be taller in this case. 👌

@joserodolfofreitas I've made some styling adjustments to properly account for the possibility of different container height of the MultiSectionDigitalClock. The scrolling should work as expected in both DatePicker and DateTimePicker cases.
Could you double-check if this issue has been resolved?

I'd be interested in releasing this change without the #8851 because the styling updates are taking longer than expected to correctly implement and finalize.

Copy link
Member

@joserodolfofreitas joserodolfofreitas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the scope of integrating the Digital clock on the DesktopDateTimePicker, I believe we're good to merge this one.
We'll need follow-ups to polish:

  1. the auto-closing strategy on both TimePicker and DateTimePicker
  2. the discrepancy between field and picker UI
    but those can be easily broken down on different PRs.

Great work bringing the digital clock to the DateTimePicker!

@LukasTy LukasTy merged commit 030a8d0 into mui:master May 26, 2023
4 checks passed
@LukasTy LukasTy deleted the digital-clock-in-date-time-picker branch May 26, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: DateTimePicker The React component. component: pickers This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] New DateTimePicker desktop behavior
5 participants