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

[DateRangeCalendar] Do not update the previewed day when hover a day and the value is empty #16819

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Mar 4, 2025

Fixes #16815

TODO: Apply the same logic to #16069 if needed

@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label Mar 4, 2025
@flaviendelangle flaviendelangle self-assigned this Mar 4, 2025
@flaviendelangle flaviendelangle added needs cherry-pick The PR should be cherry-picked to master after merge v7.x labels Mar 4, 2025
(event: React.MouseEvent<HTMLDivElement>, newPreviewRequest: PickerValidDate) => {
if (!isWithinRange(utils, newPreviewRequest, valueDayRange)) {
setRangePreviewDay(newPreviewRequest);
(event: React.MouseEvent<HTMLDivElement>, newRangePreviewDay: PickerValidDate) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

There is one scenario where this does not work: if you hover a day while value === [null, null], you don't move your mouse and you have an update of the value (from some server update).

Before this PR, the preview range would be applied.
Now it would not.

I think the trade-off is fine here, especially given than before this PR is would break already if you hovered inside the range and the value updates (since we do setRangePreviewDay(null) on line 476).
I could store the hovered date in a ref if it's not causing any preview and check when the value change, but tbh it feels like wasted complexity.

@mui-bot
Copy link

mui-bot commented Mar 4, 2025

Deploy preview: https://deploy-preview-16819--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against f09567b

@flaviendelangle flaviendelangle marked this pull request as ready for review March 4, 2025 13:28
Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

:shipit:

@flaviendelangle flaviendelangle merged commit 63570a1 into mui:master Mar 10, 2025
18 checks passed
@flaviendelangle flaviendelangle deleted the preview-perf branch March 10, 2025 10:33
Copy link

Cherry-pick PRs will be created targeting branches: v7.x

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Nice improvement! 👏
We could still optimze in other ways - not updating every single day when hoving over days with a selected value.

Screen.Recording.2025-03-10.at.13.50.09.mov

@flaviendelangle
Copy link
Member Author

If you can create a dedicated issue 🙏
I can clearly do a follow up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! needs cherry-pick The PR should be cherry-picked to master after merge v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DateRangeCalendar] Rerendering every day component on every hover change
4 participants