Skip to content

Commit

Permalink
resolve SlotProps for popperOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lhilgert9 committed May 10, 2024
1 parent a3bfdf8 commit 12e084f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/mui-material/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import clsx from 'clsx';
import useTimeout, { Timeout } from '@mui/utils/useTimeout';
import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
import { appendOwnerState } from '@mui/base/utils';
import { appendOwnerState, resolveComponentProps } from '@mui/base/utils';
import composeClasses from '@mui/utils/composeClasses';
import { alpha } from '@mui/system/colorManipulator';
import { useRtl } from '@mui/system/RtlProvider';
Expand Down Expand Up @@ -583,6 +583,16 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
}
}

const ownerState = React.useMemo(()=>({
...props,
isRtl,
arrow,
disableInteractive,
placement,
PopperComponentProp,
touch: ignoreNonTouchEvents.current,
}), [PopperComponentProp, arrow, disableInteractive, isRtl, placement, props]);

const popperOptions = React.useMemo(() => {
let tooltipModifiers = [
{
Expand All @@ -594,28 +604,18 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
},
},
];

if (slotProps.popper?.popperOptions?.modifiers || PopperProps?.popperOptions?.modifiers) {
const resolvedSlotProps = resolveComponentProps(slotProps.popper, ownerState)
if (resolvedSlotProps?.popperOptions?.modifiers || PopperProps?.popperOptions?.modifiers) {
tooltipModifiers = tooltipModifiers.concat(
slotProps.popper?.popperOptions?.modifiers ?? PopperProps?.popperOptions.modifiers,
resolvedSlotProps?.popperOptions?.modifiers ?? PopperProps?.popperOptions.modifiers,
);
}

return {
...(slotProps.popper?.popperProps ?? PopperProps?.popperOptions),
...(resolvedSlotProps?.popperProps ?? PopperProps?.popperOptions),
modifiers: tooltipModifiers,
};
}, [arrowRef, PopperProps, slotProps]);

const ownerState = {
...props,
isRtl,
arrow,
disableInteractive,
placement,
PopperComponentProp,
touch: ignoreNonTouchEvents.current,
};
}, [arrowRef, PopperProps, slotProps, ownerState]);

const classes = useUtilityClasses(ownerState);

Expand Down

0 comments on commit 12e084f

Please sign in to comment.