File tree Expand file tree Collapse file tree
packages/block-editor/src/components/block-popover Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { useMergeRefs } from '@wordpress/compose';
1010import { Popover } from '@wordpress/components' ;
1111import {
1212 forwardRef ,
13+ useCallback ,
1314 useMemo ,
1415 useReducer ,
1516 useLayoutEffect ,
@@ -52,6 +53,10 @@ function BlockPopover(
5253 0
5354 ) ;
5455
56+ const debouncedRecompute = useCallback ( ( ) => {
57+ window . requestAnimationFrame ( ( ) => forceRecomputePopoverDimensions ( ) ) ;
58+ } , [ forceRecomputePopoverDimensions ] ) ;
59+
5560 // When blocks are moved up/down, they are animated to their new position by
5661 // updating the `transform` property manually (i.e. without using CSS
5762 // transitions or animations). The animation, which can also scroll the block
@@ -64,15 +69,13 @@ function BlockPopover(
6469 return ;
6570 }
6671
67- const observer = new window . MutationObserver (
68- forceRecomputePopoverDimensions
69- ) ;
72+ const observer = new window . MutationObserver ( debouncedRecompute ) ;
7073 observer . observe ( selectedElement , { attributes : true } ) ;
7174
7275 return ( ) => {
7376 observer . disconnect ( ) ;
7477 } ;
75- } , [ selectedElement ] ) ;
78+ } , [ selectedElement , debouncedRecompute ] ) ;
7679
7780 const popoverAnchor = useMemo ( ( ) => {
7881 if (
You can’t perform that action at this time.
0 commit comments