Skip to content

Commit

Permalink
BlockSettingsDropdown: No need to cast 'clientIds' to an array (#59940)
Browse files Browse the repository at this point in the history
* BlockSettingsDropdown: No need to cast 'clientIds' to an array
* Fix clientId logic for 'onInsertBefore' and 'onInsertAfter' actions

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 72b9ffa commit 8e920f5
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 8e920f5

Please sign in to comment.