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

Fix not rerendering days when inCurrentMonth changes #1994

Merged
merged 1 commit into from
Jul 15, 2020

Conversation

dmtrKovalenko
Copy link
Member

@dmtrKovalenko dmtrKovalenko commented Jul 15, 2020

Closes #1993 and also closes #1756

The root of this issue was missing check for inCurrentMonth in React.memo. The same day with the same key was rendered in the new month, so react basically didn't change it only moved the node from one place to another one.

Didn't reproduce without reduceAnimation because transition group is mounting and unmounting the whole component on animation.

@vercel
Copy link

vercel bot commented Jul 15, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/mui-org/material-ui-pickers/q0g7dv3ql
✅ Preview: https://material-ui-picker-git-bugfix-reduceanimation-missing-re-cba64e.mui-org.vercel.app

@cypress
Copy link

cypress bot commented Jul 15, 2020



Test summary

78 0 3 0


Run details

Project material-ui-pickers
Status Passed
Commit f4b0b87
Started Jul 15, 2020 11:13 AM
Ended Jul 15, 2020 11:15 AM
Duration 01:30 💡
OS Linux Debian - 10.0
Browser Chrome 80

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Shouldn't we add a test case?

@@ -77,7 +77,7 @@ export const SlideTransition: React.SFC<SlideTransitionProps> = ({
}) => {
const classes = useStyles();
if (reduceAnimations) {
return <div className={className}>{children}</div>;
return <div className={clsx(classes.root, className)}>{children}</div>;
Copy link
Member

Choose a reason for hiding this comment

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

Should we spread too?

Suggested change
return <div className={clsx(classes.root, className)}>{children}</div>;
return <div className={clsx(classes.root, className)} {...other}>{children}</div>;

Copy link
Member Author

Choose a reason for hiding this comment

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

Here props are spreading to the TransitionGroup. So no, we don’t need to spread them

Copy link
Member

Choose a reason for hiding this comment

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

Right, because SlideTransition is private so it doesn't matter

@oliviertassinari oliviertassinari added the bug 🐛 Something isn't working label Jul 15, 2020
@@ -251,6 +251,7 @@ export const areDayPropsEqual = (prevProps: DayProps, nextProps: DayProps) => {
prevProps.showDaysOutsideCurrentMonth === nextProps.showDaysOutsideCurrentMonth &&
prevProps.disableHighlightToday === nextProps.disableHighlightToday &&
prevProps.className === nextProps.className &&
prevProps.inCurrentMonth === nextProps.inCurrentMonth &&
Copy link
Member

Choose a reason for hiding this comment

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

Didn't reproduce without reduceAnimation because transition group is mounting and unmounting the whole component on animation.

What do you think of dropping the areDayPropsEqual logic? I believe that if we drop the ButtonBase component as proposed #1674, we would make this optimization with almost no ROI.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could test it, but without this function everything is SO slow especially for dateRange picker.

Copy link
Member

@oliviertassinari oliviertassinari Jul 15, 2020

Choose a reason for hiding this comment

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

I'm confused. Here are my thoughts:

  • What's the difference with the date range picker that explains the slowness compared to the date picker?
  • We display two calendars instead of one.
  • Ok, so the slowness is only an issue with desktop as we display a single calendar on mobile.
  • On desktop we don't use reduceAnimation.
  • You said that the logic is only working if reduceAnimation

I come to the conclusion that it shouldn't have any impact on date range picker. Where is the error?

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 also works for DateRangePicker preview and in month selection and keyboard control.

Copy link
Member

@oliviertassinari oliviertassinari Jul 15, 2020

Choose a reason for hiding this comment

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

keyboard control

The focus keybroad logic could be bypassing React entirely

@dmtrKovalenko
Copy link
Member Author

I think this kind of bugs don’t need a pinning test, because you will delete this test once will see it in the future

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

I have added a note about a good opportunity to simplify the codebase with removing areDayPropsEqual in #1674

I think this kind of bugs don’t need a pinning test, because you will delete this test once will see it in the future

I agree because the probability that we will be able to drop this logic in the near future is probably 80% :)

@dmtrKovalenko
Copy link
Member Author

I am 99% sure we will not drop this logic. Hovering through JavaScript (Date range preview) is too slow if all 36 components rerenders.

@dmtrKovalenko dmtrKovalenko merged commit 6ffb24b into next Jul 15, 2020
@dmtrKovalenko dmtrKovalenko deleted the bugfix/reduceAnimation-missing-rerenders branch July 15, 2020 16:35
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 15, 2020

Good point, I didn't account for the date range selection, for which, we might not want to bypass React for rendering it.

In this case, we miss a test case at 99% ;)

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 15, 2020

Especially considering that it fixes two GitHub issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MobileDateTimePicker with reducedAnimations is missing days Wrong highlighting of days out of the month
2 participants