File tree Expand file tree Collapse file tree
src/widget/components/graphs/world-map Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,23 +107,36 @@ export const WorldMap = (props: WorldMapProps) => {
107107 $el . vectorMap ( 'get' , 'mapObject' ) || $el . data ( 'mapObject' ) ;
108108
109109 const resizeMap = ( ) => {
110+ // Keep map sizing in sync with the host container
110111 const map = getMap ( ) ;
111112 const host = document . getElementById ( canvasId ) ;
112113 if ( ! map || ! host ) {
113114 return ;
114115 }
115116
116- const { height } = host . getBoundingClientRect ( ) ;
117+ // Prefer measured heights, fall back to computed CSS or a sane default
118+ const { height : rectHeight } = host . getBoundingClientRect ( ) ;
119+ const cssHeight = Number . parseFloat (
120+ globalThis . getComputedStyle ?.( host ) ?. height || '0'
121+ ) ;
122+
123+ const candidateHeight =
124+ rectHeight ||
125+ host . clientHeight ||
126+ host . offsetHeight ||
127+ cssHeight ||
128+ 250 ;
129+
117130 const targetHeight = Math . max (
118131 200 ,
119- Math . min (
120- 800 ,
121- Math . round (
122- height || host . clientHeight || host . offsetHeight || map . height || 0
123- )
124- )
132+ Math . min ( 800 , Math . round ( candidateHeight ) )
125133 ) ;
126134
135+ // Defensive guard: avoid NaN or zero-height updates
136+ if ( ! Number . isFinite ( targetHeight ) || targetHeight <= 0 ) {
137+ return ;
138+ }
139+
127140 map . container ?. css ?.( { width : '100%' , height : `${ targetHeight } px` } ) ;
128141 map . updateSize ?.( ) ;
129142 } ;
You can’t perform that action at this time.
0 commit comments