[CYS] Show tooltips in delete and shuffle buttons (#48465)

* Show tooltips in delete and shuffle buttons

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Alba Rincón 2024-06-14 10:21:44 +02:00 committed by GitHub
parent 641370aa4e
commit c18dbb1ce4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 38 deletions

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { Button, ToolbarButton, ToolbarGroup } from '@wordpress/components';
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
import { useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { trash } from '@wordpress/icons';
@ -22,18 +22,17 @@ export default function Delete( {
return (
<ToolbarGroup>
<ToolbarButton>
<Button
label={ __( 'Remove', 'woocommerce' ) }
icon={ trash }
onClick={ () => {
removeBlock( clientId );
if ( nextBlockClientId ) {
selectBlock( nextBlockClientId );
}
} }
/>
</ToolbarButton>
<ToolbarButton
showTooltip={ true }
label={ __( 'Remove', 'woocommerce' ) }
icon={ trash }
onClick={ () => {
removeBlock( clientId );
if ( nextBlockClientId ) {
selectBlock( nextBlockClientId );
}
} }
/>
</ToolbarGroup>
);
}

View File

@ -7,13 +7,7 @@
import { useDispatch, useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import {
Button,
Path,
SVG,
ToolbarButton,
ToolbarGroup,
} from '@wordpress/components';
import { Path, SVG, ToolbarButton, ToolbarGroup } from '@wordpress/components';
import {
unlock,
// @ts-expect-error No types for this exist yet.
@ -108,24 +102,22 @@ export default function Shuffle( { clientId }: { clientId: string } ) {
return (
<ToolbarGroup>
<ToolbarButton>
<Button
label={ __( 'Shuffle', 'woocommerce' ) }
icon={ shuffleIcon }
onClick={ () => {
const nextPattern = getNextPattern();
// @ts-expect-error - attributes is marked as readonly.
nextPattern.blocks[ 0 ].attributes = {
...nextPattern.blocks[ 0 ].attributes,
metadata: {
...nextPattern.blocks[ 0 ].attributes.metadata,
categories,
},
};
replaceBlocks( clientId, nextPattern.blocks );
} }
/>
</ToolbarButton>
<ToolbarButton
label={ __( 'Shuffle', 'woocommerce' ) }
icon={ shuffleIcon }
onClick={ () => {
const nextPattern = getNextPattern();
// @ts-expect-error - attributes is marked as readonly.
nextPattern.blocks[ 0 ].attributes = {
...nextPattern.blocks[ 0 ].attributes,
metadata: {
...nextPattern.blocks[ 0 ].attributes.metadata,
categories,
},
};
replaceBlocks( clientId, nextPattern.blocks );
} }
/>
</ToolbarGroup>
);
}

View File

@ -2,4 +2,8 @@
.block-editor-block-mover__drag-handle {
display: none;
}
.block-editor-block-mover {
padding: 0;
}
}

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
CYS - Show tooltips on the Shuffle and Delete buttons in the assembler toolbar.