Skip to content

Commit

Permalink
BlockSettingsDropdown: No need to cast 'clientIds' to an array (WordP…
Browse files Browse the repository at this point in the history
…ress#59940)

* BlockSettingsDropdown: No need to cast 'clientIds' to an array
* Fix clientId logic for 'onInsertBefore' and 'onInsertAfter' actions

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored and carstingaxion committed Mar 27, 2024
1 parent 1c5bbda commit 21c8e1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
10 changes: 2 additions & 8 deletions packages/block-editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,10 @@ export default function BlockActions( {
return removeBlocks( clientIds, updateSelection );
},
onInsertBefore() {
const clientId = Array.isArray( clientIds )
? clientIds[ 0 ]
: clientId;
insertBeforeBlock( clientId );
insertBeforeBlock( clientIds[ 0 ] );
},
onInsertAfter() {
const clientId = Array.isArray( clientIds )
? clientIds[ clientIds.length - 1 ]
: clientId;
insertAfterBlock( clientId );
insertAfterBlock( clientIds[ clientIds.length - 1 ] );
},
onMoveTo() {
setNavigationMode( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ function CopyMenuItem( { clientIds, onCopy, label } ) {
export function BlockSettingsDropdown( {
block,
clientIds,
__experimentalSelectBlock,
children,
__experimentalSelectBlock,
__unstableDisplayLocation,
...props
} ) {
// Get the client id of the current block for this menu, if one is set.
const currentClientId = block?.clientId;
const blockClientIds = Array.isArray( clientIds )
? clientIds
: [ clientIds ];
const count = blockClientIds.length;
const firstBlockClientId = blockClientIds[ 0 ];
const count = clientIds.length;
const firstBlockClientId = clientIds[ 0 ];
const {
firstParentClientId,
onlyBlock,
Expand Down

0 comments on commit 21c8e1a

Please sign in to comment.