@@ -9,6 +9,7 @@ export const computeTooltipPosition = async ({
99 offset : offsetValue = 10 ,
1010 strategy = 'absolute' ,
1111 middlewares = [ offset ( Number ( offsetValue ) ) , flip ( ) , shift ( { padding : 5 } ) ] ,
12+ border = null ,
1213} : IComputePositions ) => {
1314 if ( ! elementReference ) {
1415 // elementReference can be null or undefined and we will not compute the position
@@ -31,7 +32,7 @@ export const computeTooltipPosition = async ({
3132 strategy,
3233 middleware,
3334 } ) . then ( ( { x, y, placement, middlewareData } ) => {
34- const styles = { left : `${ x } px` , top : `${ y } px` }
35+ const styles = { left : `${ x } px` , top : `${ y } px` , border }
3536
3637 const { x : arrowX , y : arrowY } = middlewareData . arrow ?? { x : 0 , y : 0 }
3738
@@ -43,12 +44,22 @@ export const computeTooltipPosition = async ({
4344 left : 'right' ,
4445 } [ placement . split ( '-' ) [ 0 ] ] ?? 'bottom'
4546
47+ const borderSide =
48+ border &&
49+ {
50+ top : { borderBottom : border , borderRight : border } ,
51+ right : { borderBottom : border , borderLeft : border } ,
52+ bottom : { borderTop : border , borderLeft : border } ,
53+ left : { borderTop : border , borderRight : border } ,
54+ } [ placement . split ( '-' ) [ 0 ] ]
55+
4656 const arrowStyle = {
4757 left : arrowX != null ? `${ arrowX } px` : '' ,
4858 top : arrowY != null ? `${ arrowY } px` : '' ,
4959 right : '' ,
5060 bottom : '' ,
51- [ staticSide ] : '-4px' ,
61+ ...{ ...borderSide } ,
62+ [ staticSide ] : '-5px' ,
5263 }
5364
5465 return { tooltipStyles : styles , tooltipArrowStyles : arrowStyle , place : placement }
0 commit comments