Skip to content

Commit

Permalink
Use block context to look up bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed May 16, 2024
1 parent 3771101 commit f341e60
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}, [] );
Expand Down

0 comments on commit f341e60

Please sign in to comment.