@@ -247,6 +247,7 @@ function useProximityHandlers(
247
247
props : ICoachmarkProps ,
248
248
translateAnimationContainer : React . RefObject < HTMLDivElement > ,
249
249
openCoachmark : ( ) => void ,
250
+ setBounds : ( bounds : IRectangle | undefined ) => void ,
250
251
) {
251
252
const { setTimeout, clearTimeout } = useSetTimeout ( ) ;
252
253
@@ -285,6 +286,7 @@ function useProximityHandlers(
285
286
timeoutIds . push (
286
287
setTimeout ( ( ) : void => {
287
288
setTargetElementRect ( ) ;
289
+ setBounds ( getBounds ( props . isPositionForced , props . positioningContainerProps ) ) ;
288
290
} , 100 ) ,
289
291
) ;
290
292
} ) ;
@@ -402,15 +404,6 @@ function useDeprecationWarning(props: ICoachmarkProps) {
402
404
}
403
405
}
404
406
405
- function useGetBounds ( props : ICoachmarkProps ) : IRectangle | undefined {
406
- const async = useAsync ( ) ;
407
- const [ bounds , setBounds ] = React . useState < IRectangle | undefined > ( ) ;
408
- React . useEffect ( ( ) => {
409
- async . requestAnimationFrame ( ( ) => setBounds ( getBounds ( props . isPositionForced , props . positioningContainerProps ) ) ) ;
410
- } , [ async , props . isPositionForced , props . positioningContainerProps ] ) ;
411
- return bounds ;
412
- }
413
-
414
407
const COMPONENT_NAME = 'CoachmarkBase' ;
415
408
416
409
export const CoachmarkBase : React . FunctionComponent < ICoachmarkProps > = React . forwardRef <
@@ -426,14 +419,21 @@ export const CoachmarkBase: React.FunctionComponent<ICoachmarkProps> = React.for
426
419
const [ isCollapsed , openCoachmark ] = useCollapsedState ( props , entityInnerHostElementRef ) ;
427
420
const [ beakPositioningProps , transformOrigin ] = useBeakPosition ( props , targetAlignment , targetPosition ) ;
428
421
const [ isMeasuring , entityInnerHostRect ] = useEntityHostMeasurements ( props , entityInnerHostElementRef ) ;
422
+ const [ bounds , setBounds ] = React . useState < IRectangle | undefined > (
423
+ getBounds ( props . isPositionForced , props . positioningContainerProps ) ,
424
+ ) ;
429
425
const alertText = useAriaAlert ( props ) ;
430
426
const entityHost = useAutoFocus ( props ) ;
431
427
432
428
useListeners ( props , translateAnimationContainer , openCoachmark ) ;
433
429
useComponentRef ( props ) ;
434
- useProximityHandlers ( props , translateAnimationContainer , openCoachmark ) ;
430
+ useProximityHandlers ( props , translateAnimationContainer , openCoachmark , setBounds ) ;
435
431
useDeprecationWarning ( props ) ;
436
432
433
+ React . useEffect ( ( ) => {
434
+ setBounds ( getBounds ( props . isPositionForced , props . positioningContainerProps ) ) ;
435
+ } , [ props . isPositionForced , props . positioningContainerProps ] ) ;
436
+
437
437
const {
438
438
beaconColorOne,
439
439
beaconColorTwo,
@@ -484,7 +484,7 @@ export const CoachmarkBase: React.FunctionComponent<ICoachmarkProps> = React.for
484
484
finalHeight = { finalHeight }
485
485
ref = { forwardedRef }
486
486
onPositioned = { onPositioned }
487
- bounds = { useGetBounds ( props ) }
487
+ bounds = { bounds }
488
488
{ ...positioningContainerProps }
489
489
>
490
490
< div className = { classNames . root } >
0 commit comments