Skip to content

Commit

Permalink
Update bounds unconditionally from single-run layout effect
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Jul 15, 2022
1 parent 3d8d486 commit 976b4b3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/components/src/focal-point-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useEffect, useRef, useState } from '@wordpress/element';
import {
__experimentalUseDragging as useDragging,
useInstanceId,
useIsomorphicLayoutEffect,
} from '@wordpress/compose';

/**
Expand Down Expand Up @@ -79,12 +80,8 @@ export default function FocalPointPicker( {
return () => defaultView.removeEventListener( 'resize', updateBounds );
}, [] );

useEffect( () => {
// Updates bounds if there’s no media (and thus no load event to trigger
// a bounds update). Even then, this will only have an effect if the
// component is styled to non-default dimensions.
if ( ! url ) refUpdateBounds.current();
}, [ url ] );
// Updates the bounds to cover cases of unspecified media or load failures.
useIsomorphicLayoutEffect( () => void refUpdateBounds.current(), [] );

const { startDrag, endDrag, isDragging } = useDragging( {
onDragStart: ( event ) => {
Expand Down

0 comments on commit 976b4b3

Please sign in to comment.