Skip to content

[pickers] Fix transformOrigin resolving based on popper placement #18206

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

Merged
merged 4 commits into from
Jun 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface PickerPopperSlotProps {
/**
* Props passed down to [Popper](https://mui.com/material-ui/api/popper/) component.
*/
popper?: SlotComponentPropsFromProps<PopperProps, {}, PickerPopperOwnerState>;
popper?: SlotComponentPropsFromProps<PopperProps, {}, 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.

To have the final popperPlacement value here, we would need to resolve the slotProps.popper twice. 🙈
I opted for a slight BC by removing this field from the type to avoid inconsistencies or ugly and less performant code. 🙈

Copy link
Member

Choose a reason for hiding this comment

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

Not great but fine doing it :/

}

export interface ExportedPickerPopperProps {
Expand Down Expand Up @@ -100,7 +100,7 @@ const useUtilityClasses = (classes: Partial<PickerPopperClasses> | undefined) =>
const PickerPopperRoot = styled(MuiPopper, {
name: 'MuiPickerPopper',
slot: 'Root',
})(({ theme }) => ({
})<{ ownerState: PickerOwnerState }>(({ theme }) => ({
zIndex: theme.zIndex.modal,
}));

Expand Down Expand Up @@ -368,10 +368,6 @@ export function PickerPopper(inProps: PickerPopperProps) {

const classes = useUtilityClasses(classesProp);
const { ownerState: pickerOwnerState, rootRefObject } = usePickerPrivateContext();
const ownerState: PickerPopperOwnerState = {
...pickerOwnerState,
popperPlacement: placement,
};

const handleClickAway = useEventCallback(() => {
if (viewContainerRole === 'tooltip') {
Expand Down Expand Up @@ -423,9 +419,14 @@ export function PickerPopper(inProps: PickerPopperProps) {
onKeyDown: handleKeyDown,
},
className: classes.root,
ownerState,
ownerState: pickerOwnerState,
});

const ownerState = React.useMemo(
() => ({ ...pickerOwnerState, popperPlacement: popperProps.placement }),
[pickerOwnerState, popperProps.placement],
);

return (
<Popper {...popperProps}>
{({ TransitionProps }) => (
Expand Down