@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
import HTMLElementType from '@mui/utils/HTMLElementType' ;
5
5
import useLazyRef from '@mui/utils/useLazyRef' ;
6
6
import { styled , useThemeProps } from '@mui/material/styles' ;
7
- import Popper , { PopperPlacementType , PopperProps } from '@mui/material/Popper' ;
7
+ import Popper , { PopperProps } from '@mui/material/Popper' ;
8
8
import NoSsr from '@mui/material/NoSsr' ;
9
9
import { useSvgRef } from '../hooks/useSvgRef' ;
10
10
import { TriggerOptions , usePointerType } from './utils' ;
@@ -122,17 +122,24 @@ function ChartsTooltipContainer(inProps: ChartsTooltipContainerProps) {
122
122
{
123
123
name : 'offset' ,
124
124
options : {
125
- offset : ( { placement } : { placement : PopperPlacementType } ) => {
125
+ offset : ( ) => {
126
126
if ( pointerType ?. pointerType !== 'touch' ) {
127
- return [ 0 , 0 ] ;
127
+ return [ 0 , 8 ] ;
128
128
}
129
-
130
- const isBottom = placement . startsWith ( 'bottom' ) ;
131
- const placementOffset = isBottom ? 32 : 8 ;
132
- return [ 0 , pointerType . height + placementOffset ] ;
129
+ return [ 0 , 64 ] ;
133
130
} ,
134
131
} ,
135
132
} ,
133
+ ...( pointerType ?. pointerType === 'mouse'
134
+ ? [ ] // Keep default behavior
135
+ : [
136
+ {
137
+ name : 'flip' ,
138
+ options : {
139
+ fallbackPlacements : [ 'top-end' , 'top-start' , 'bottom-end' , 'bottom' ] ,
140
+ } ,
141
+ } ,
142
+ ] ) ,
136
143
] ,
137
144
[ pointerType ] ,
138
145
) ;
@@ -147,9 +154,7 @@ function ChartsTooltipContainer(inProps: ChartsTooltipContainerProps) {
147
154
< ChartsTooltipRoot
148
155
className = { classes ?. root }
149
156
open = { popperOpen }
150
- placement = {
151
- pointerType ?. pointerType === 'mouse' ? ( 'right-start' as const ) : ( 'top' as const )
152
- }
157
+ placement = { pointerType ?. pointerType === 'mouse' ? 'right-start' : 'top' }
153
158
popperRef = { popperRef }
154
159
anchorEl = { anchorEl }
155
160
modifiers = { modifiers }
0 commit comments