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] Use the new ownerState in <PickersCalendarHeader />, <PickersArrowSwitcher /> and <DayCalendarSkeleton /> #15499

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Nov 20, 2024

Part of #14475

@flaviendelangle flaviendelangle added breaking change component: pickers This is the name of the generic UI component, not the React module! labels Nov 20, 2024
@flaviendelangle flaviendelangle self-assigned this Nov 20, 2024
@mui-bot
Copy link

mui-bot commented Nov 20, 2024

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

Generated by 🚫 dangerJS against 4acd00f

<DayCalendarSkeletonDay
key={index2}
variant="circular"
width={DAY_SIZE}
height={DAY_SIZE}
className={classes.daySkeleton}
ownerState={{ day }}
data-day-in-month={dayInMonth}
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 can create a DayCalendarSkeletonOwnerState but the component is probably not used a lot and even less overriden with styleOverrides so I went with simplicity here


export type SlideDirection = 'right' | 'left';

interface PickerSlideTransitionOwnerState extends PickerOwnerState {
Copy link
Member Author

Choose a reason for hiding this comment

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

It is not used in any styleOverrides, only in useUtilityClasses but I'm also unifying the parameters of this hook

@flaviendelangle flaviendelangle marked this pull request as ready for review November 28, 2024 12:49
@flaviendelangle flaviendelangle changed the title [pickers] Use the new ownerState in PickersCalendarHeader, PickersArrowSwitcher and DayCalendarSkeleton [pickers] Use the new ownerState in <PickersCalendarHeader />, <PickersArrowSwitcher /> and <DayCalendarSkeleton /> Nov 28, 2024
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.

Looks good ... just a small suggestion that might apply to other areas as well ... not blocking! :shipit:

Comment on lines +135 to +137
const { ownerState: pickerOwnerState } = usePickerPrivateContext();
const ownerState = { ...pickerOwnerState, slideDirection };
const classes = useUtilityClasses(classesProp, ownerState);
Copy link
Member

Choose a reason for hiding this comment

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

very small performance thing: would it make sense here to prevent creating 2 additional objects?

Suggested change
const { ownerState: pickerOwnerState } = usePickerPrivateContext();
const ownerState = { ...pickerOwnerState, slideDirection };
const classes = useUtilityClasses(classesProp, ownerState);
const classes = useUtilityClasses(classesProp, {
...usePickerPrivateContext().ownerState,
slideDirection,
});

Copy link
Member Author

@flaviendelangle flaviendelangle Nov 28, 2024

Choose a reason for hiding this comment

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

For me we have the exact same amount of objects created with both approaches.
We only skip the creation of the pickerOwnerState and ownerState` variables (which are reference based since it's an object so for me it's negligeable)

@flaviendelangle flaviendelangle merged commit 7cc3ead into mui:master Nov 28, 2024
16 checks passed
@flaviendelangle flaviendelangle deleted the ownerState-various branch November 28, 2024 14:21
LukasTy pushed a commit to LukasTy/mui-x that referenced this pull request Dec 19, 2024
…PickersArrowSwitcher />` and `<DayCalendarSkeleton />` (mui#15499)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change 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.

3 participants