@@ -104,22 +104,25 @@ export function determineAutoPosition(
104104 removeEntry < TooltipPosition > ( possiblePositions , "left" ) ;
105105 }
106106
107- // strip alignment from position
107+ // Check if user requested a specific alignment
108+ const userRequestedAlignment =
109+ desiredTooltipPosition && desiredTooltipPosition . includes ( "-aligned" ) ;
110+
111+ // strip alignment from position for base position checking
112+ let basePosition = desiredTooltipPosition ;
108113 if ( desiredTooltipPosition ) {
109114 // ex: "bottom-right-aligned"
110115 // should return 'bottom'
111- desiredTooltipPosition = desiredTooltipPosition . split (
112- "-"
113- ) [ 0 ] as TooltipPosition ;
116+ basePosition = desiredTooltipPosition . split ( "-" ) [ 0 ] as TooltipPosition ;
114117 }
115118
116119 if ( possiblePositions . length ) {
117120 // Pick the first valid position, in order
118121 calculatedPosition = possiblePositions [ 0 ] ;
119122
120- if ( possiblePositions . includes ( desiredTooltipPosition ) ) {
123+ if ( possiblePositions . includes ( basePosition ) ) {
121124 // If the requested position is in the list, choose that
122- calculatedPosition = desiredTooltipPosition ;
125+ calculatedPosition = basePosition ;
123126 }
124127 }
125128
@@ -149,13 +152,22 @@ export function determineAutoPosition(
149152 ] ;
150153 }
151154
152- calculatedPosition =
153- determineAutoAlignment (
154- targetOffset . absoluteLeft ,
155- tooltipWidth ,
156- windowSize . width ,
157- desiredAlignment
158- ) || defaultAlignment ;
155+ // If user requested a specific alignment, use it directly
156+ if (
157+ userRequestedAlignment &&
158+ desiredAlignment . includes ( desiredTooltipPosition )
159+ ) {
160+ calculatedPosition = desiredTooltipPosition ;
161+ } else {
162+ // No specific alignment requested, use auto-alignment
163+ calculatedPosition =
164+ determineAutoAlignment (
165+ targetOffset . absoluteLeft ,
166+ tooltipWidth ,
167+ windowSize . width ,
168+ desiredAlignment
169+ ) || defaultAlignment ;
170+ }
159171 }
160172
161173 return calculatedPosition ;
0 commit comments