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] Do not apply the current time when no date provided in DayPicker #4649

Merged
merged 2 commits into from
May 2, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Apr 25, 2022

Fixes #4449

  • If we use the DatePicker or DateTimePicker, when clicking on a date for the 1st time, it should set the time to 00:00:00not the current time

  • Add tests

@flaviendelangle flaviendelangle self-assigned this Apr 25, 2022
@flaviendelangle flaviendelangle marked this pull request as draft April 25, 2022 15:13
@mui-bot
Copy link

mui-bot commented Apr 25, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 262.4 507.9 444.2 405.54 102.747
Sort 100k rows ms 448 925.8 714.7 695.2 161.617
Select 100k rows ms 163.8 201.7 179.8 181.38 15.811
Deselect 100k rows ms 131.2 235.8 176 179.4 43.807

Generated by 🚫 dangerJS against 0f4192d

@flaviendelangle flaviendelangle added bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! component: DateTimePicker The React component. component: DatePicker The React component. labels Apr 25, 2022
import { DayPicker } from './DayPicker';
import { adapterToUse, createPickerRenderer } from '../../../../test/utils/pickers-utils';

describe('<DayPicker />', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I added the test directly on DayPicker, I think the structure of the pickers favors more unit tests on the smaller components.

@flaviendelangle flaviendelangle marked this pull request as ready for review April 25, 2022 15:43
Comment on lines +17 to +23
focusedDay={null}
onFocusedDayChange={() => {}}
onMonthSwitchingAnimationEnd={() => {}}
isDateDisabled={() => false}
isMonthSwitchingAnimating={false}
slideDirection="right"
reduceAnimations={false}
Copy link
Member

Choose a reason for hiding this comment

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

Why do you define all those props? Is it for performance improvement?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's because DayPicker being an internal component, it was built with almost all its props required and I did not want to change its api at all.

But some default value could probably be inside DayPicker instead of higher in the component chain.

@@ -139,12 +139,20 @@ export function DayPicker<TDate>(props: PickersCalendarProps<TDate>) {
if (readOnly) {
return;
}

// TODO possibly buggy line figure out and add tests
Copy link
Member

Choose a reason for hiding this comment

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

Now that it's tested, the comment could be removed, or at least remove 'line' otherwise in a few months we will wonder why let finalDate can be buggy

Suggested change
// TODO possibly buggy line figure out and add tests
// TODO possibly buggy figure out and add tests

Copy link
Member Author

Choose a reason for hiding this comment

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

I found the issue related to this comment ealier today #4703

I think to problem is that some date library represents dates as array so this check is problematic and we should pass an isRange boolean instead to differentiate ranges and mono dates.

Copy link
Member

Choose a reason for hiding this comment

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

Good to know 👍

@flaviendelangle flaviendelangle merged commit 1d213a7 into mui:master May 2, 2022
@flaviendelangle flaviendelangle deleted the midnight-default branch May 2, 2022 08:05
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: DatePicker The React component. component: DateTimePicker The React component. component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] The minutes and seconds default value is taken from current date instead of being 00
3 participants