@@ -131,15 +131,12 @@ export default function useLegendPosition({
131131 if ( root instanceof HTMLElement && legendContent ) {
132132 const mapRootBounds = root . getBoundingClientRect ( ) ;
133133 const legendRect = legendContent . getBoundingClientRect ( ) ;
134+ const remainingHeight =
135+ mapRootBounds . bottom - ( legendRect . top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN . bottom ) ;
134136 // Use maxContentHeight if available, otherwise fall back to viewport-based calculation
135137 const maxHeight = maxContentHeight
136- ? Math . min (
137- maxContentHeight ,
138- mapRootBounds . bottom -
139- ( legendRect . top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN . bottom )
140- )
141- : mapRootBounds . bottom -
142- ( legendRect . top + MAP_CONTROL_HEADER_FULL_HEIGHT + MARGIN . bottom ) ;
138+ ? Math . min ( maxContentHeight , remainingHeight )
139+ : remainingHeight ;
143140 const nextHeight = Math . min (
144141 maxHeight ,
145142 Math . max ( MIN_CONTENT_HEIGHT , startHeightRef . current + deltaY )
@@ -178,7 +175,7 @@ export default function useLegendPosition({
178175 if ( maxContentHeight && contentHeight > 0 && contentHeight > maxContentHeight ) {
179176 onChangeSettings ( { contentHeight : maxContentHeight } ) ;
180177 }
181- } , [ mapWidth , mapHeight , contentHeight , onChangeSettings , maxContentHeight ] ) ;
178+ } , [ mapWidth , mapHeight , contentHeight , onChangeSettings , maxContentHeight , legendContentRef ] ) ;
182179
183180 return { positionStyles, updatePosition, contentHeight, maxContentHeight, startResize, resize} ;
184181}
0 commit comments