[CYS - Full Composability] Select the next block after deleting the selected one (#48316)
* Select the next block after deleting one * Add changefile(s) from automation for the following project(s): woocommerce * Fix lint error * Check if next block client is defined --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
ccbb811d7d
commit
9d114c6d2d
|
@ -10,9 +10,15 @@ import {
|
|||
// @ts-expect-error missing type
|
||||
} from '@wordpress/block-editor';
|
||||
|
||||
export default function Delete( { clientId }: { clientId: string } ) {
|
||||
export default function Delete( {
|
||||
clientId,
|
||||
nextBlockClientId,
|
||||
}: {
|
||||
clientId: string;
|
||||
nextBlockClientId: string | undefined;
|
||||
} ) {
|
||||
// @ts-expect-error missing type
|
||||
const { removeBlock } = useDispatch( blockEditorStore );
|
||||
const { removeBlock, selectBlock } = useDispatch( blockEditorStore );
|
||||
|
||||
return (
|
||||
<ToolbarGroup>
|
||||
|
@ -22,6 +28,9 @@ export default function Delete( { clientId }: { clientId: string } ) {
|
|||
icon={ trash }
|
||||
onClick={ () => {
|
||||
removeBlock( clientId );
|
||||
if ( nextBlockClientId ) {
|
||||
selectBlock( nextBlockClientId );
|
||||
}
|
||||
} }
|
||||
/>
|
||||
</ToolbarButton>
|
||||
|
|
|
@ -144,7 +144,10 @@ export const Toolbar = () => {
|
|||
/>
|
||||
</ToolbarGroup>
|
||||
<Shuffle clientId={ selectedBlockClientId } />
|
||||
<Delete clientId={ selectedBlockClientId } />
|
||||
<Delete
|
||||
clientId={ selectedBlockClientId }
|
||||
nextBlockClientId={ nextBlock?.clientId }
|
||||
/>
|
||||
</>
|
||||
</WPToolbar>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: fix
|
||||
|
||||
CYS - Select the next block after deleting the selected one (instead of the header).
|
Loading…
Reference in New Issue