diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index f6fd0e86feb1b3..5d7ee13b1591db 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -111,6 +111,13 @@ export function isBlockValid( state, clientId ) { return !! block && block.isValid; } +/** + * Variable to avoid processing bindings recursively. + * + * @type {boolean} + */ +let isProcessingBindings; + /** * Returns a block's attributes given its client ID, or null if no block exists with * the client ID. @@ -135,9 +142,10 @@ export const getBlockAttributes = createRegistrySelector( // Change attribute values if bindings are present. const bindings = blockAttributes?.metadata?.bindings; - if ( ! bindings ) { + if ( ! bindings || isProcessingBindings ) { return blockAttributes; } + isProcessingBindings = true; const sources = unlock( select( blocksStore ) @@ -182,6 +190,7 @@ export const getBlockAttributes = createRegistrySelector( } } + isProcessingBindings = false; return blockAttributes; } );