From c56926d4f7f4b869a83d381947e2db509e308fa4 Mon Sep 17 00:00:00 2001 From: Ricardo Artemio Morales Date: Thu, 16 May 2024 02:22:54 +0200 Subject: [PATCH] Use block context to look up bindings --- packages/block-editor/src/hooks/block-bindings.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index d5604ad2f9070e..aa027d87925809 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -13,22 +13,23 @@ import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ -import { store as blockEditorStore } from '../store'; import { unlock } from '../lock-unlock'; import InspectorControls from '../components/inspector-controls'; +import { + blockBindingsKey, + useBlockEditContext, +} from '../components/block-edit/context'; export const BlockBindingsPanel = () => { - const { bindings, sources } = useSelect( ( select ) => { - const { getSelectedBlockClientId, getBlock } = - select( blockEditorStore ); - const _selectedBlockClientId = getSelectedBlockClientId(); + const blockEditContext = useBlockEditContext(); + const bindings = blockEditContext[ blockBindingsKey ]; + + const { sources } = useSelect( ( select ) => { const _sources = unlock( select( blocksStore ) ).getAllBlockBindingsSources(); return { - bindings: getBlock( _selectedBlockClientId ).attributes?.metadata - ?.bindings, sources: _sources, }; }, [] );