@@ -5,6 +5,7 @@ import type { DOMManager } from '../../dom/domManager';
5
5
import type { LocaleManager } from '../../locale/localeManager' ;
6
6
import { type Bounds , type Placement , calculatePlacement } from '../../util/placement' ;
7
7
import { BaseProperties } from '../../util/properties' ;
8
+ import { SizeMonitor } from '../../util/sizeMonitor' ;
8
9
import {
9
10
ARRAY_OF ,
10
11
BOOLEAN ,
@@ -372,7 +373,6 @@ export class Tooltip extends BaseProperties {
372
373
}
373
374
374
375
element . innerHTML = html ;
375
- this . _elementSize = { width : element . clientWidth , height : element . clientHeight } ;
376
376
} else if ( element == null || element . innerHTML === '' ) {
377
377
this . toggle ( false ) ;
378
378
return ;
@@ -454,9 +454,17 @@ export class Tooltip extends BaseProperties {
454
454
}
455
455
456
456
if ( visible ) {
457
- // We can only measure the element when it's actually visible
458
- // This removes a possible jump for the tooltip
459
- this . updateTooltipPosition ( ) ;
457
+ // Avoid reading the tooltip size immediately after a DOM mutation, wait for
458
+ // a natural layout before positioning the tooltip.
459
+ SizeMonitor . singleShot ( this . element , ( size ) => {
460
+ if ( ! this . _visible ) return ;
461
+
462
+ this . _elementSize = size ;
463
+
464
+ // We can only measure the element when it's actually visible
465
+ // This removes a possible jump for the tooltip
466
+ this . updateTooltipPosition ( ) ;
467
+ } ) ;
460
468
}
461
469
}
462
470
0 commit comments