Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Feb 27, 2023
1 parent bf2efa5 commit c0f4406
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
removeBlock,
} = dispatch( blockEditorStore );

const queue = [];
let rIC;

// Do not add new properties here, use `useDispatch` instead to avoid
// leaking new props to the public API (editor.BlockListBlock filter).
return {
Expand All @@ -330,7 +333,20 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
? multiSelectedBlockClientIds
: [ clientId ];

updateBlockAttributes( clientIds, newAttributes );
queue.push( () => {
updateBlockAttributes( clientIds, newAttributes );
} );

window.cancelIdleCallback( rIC );
rIC = window.requestIdleCallback(
() => {
registry.batch( () => {
queue.forEach( ( callback ) => callback() );
queue.length = 0;
} );
},
{ timeout: 1000 }
);
},
onInsertBlocks( blocks, index ) {
const { rootClientId } = ownProps;
Expand Down

0 comments on commit c0f4406

Please sign in to comment.