@@ -17,7 +17,8 @@ export default function QuestionTooltip(props: TooltipProps) {
1717 const [ position , setPosition ] = createSignal < {
1818 x : number ;
1919 align : TooltipAlignment ;
20- } > ( { x : 0 , align : TooltipAlignment . Center } ) ;
20+ containerWidth : number ;
21+ } > ( { x : 0 , align : TooltipAlignment . Center , containerWidth : 0 } ) ;
2122
2223 let containerRef : HTMLDivElement | undefined ;
2324
@@ -44,7 +45,7 @@ export default function QuestionTooltip(props: TooltipProps) {
4445 if ( containerRef ) {
4546 const rect = containerRef . getBoundingClientRect ( ) ;
4647 const align = determineAlignment ( rect ) ;
47- setPosition ( { x : 0 , align } ) ;
48+ setPosition ( { x : 0 , align, containerWidth : rect . width } ) ;
4849 }
4950 setIsVisible ( true ) ;
5051 } ;
@@ -87,10 +88,15 @@ export default function QuestionTooltip(props: TooltipProps) {
8788 class = { `absolute w-3 h-3 bg-white border-t border-l border-gray-200 rotate-45 -top-[7px] ${
8889 position ( ) . align === TooltipAlignment . Center
8990 ? "left-1/2 -translate-x-1/2"
90- : position ( ) . align === TooltipAlignment . Left
91- ? "left-3"
92- : "right-3"
91+ : ""
9392 } `}
93+ style = {
94+ position ( ) . align === TooltipAlignment . Left
95+ ? { left : `${ position ( ) . containerWidth / 2 - 6 } px` }
96+ : position ( ) . align === TooltipAlignment . Right
97+ ? { right : `${ position ( ) . containerWidth / 2 - 6 } px` }
98+ : { }
99+ }
94100 />
95101 </ div >
96102 </ Show >
0 commit comments