Skip to content

Commit

Permalink
Block Editor: Group 'onRemove' callback with other public APIs (#67551)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2024
1 parent d017783 commit cc5a2b7
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import {
memo,
useCallback,
RawHTML,
useContext,
useMemo,
} from '@wordpress/element';
import { memo, RawHTML, useContext, useMemo } from '@wordpress/element';
import {
getBlockType,
getSaveContent,
Expand All @@ -28,7 +22,7 @@ import {
store as blocksStore,
} from '@wordpress/blocks';
import { withFilters } from '@wordpress/components';
import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
import { withDispatch, useSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { safeHTML } from '@wordpress/dom';

Expand Down Expand Up @@ -103,6 +97,7 @@ function BlockListBlock( {
wrapperProps,
setAttributes,
onReplace,
onRemove,
onInsertBlocksAfter,
onMerge,
toggleSelection,
Expand All @@ -113,11 +108,6 @@ function BlockListBlock( {
themeSupportsLayout,
...context
} = useContext( PrivateBlockContext );
const { removeBlock } = useDispatch( blockEditorStore );
const onRemove = useCallback(
() => removeBlock( clientId ),
[ clientId, removeBlock ]
);

const parentLayout = useLayout() || {};

Expand Down Expand Up @@ -537,6 +527,9 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
initialPosition
);
},
onRemove() {
removeBlock( ownProps.clientId );
},
toggleSelection( selectionEnabled ) {
toggleSelection( selectionEnabled );
},
Expand Down

0 comments on commit cc5a2b7

Please sign in to comment.