Skip to content

Commit

Permalink
Use getBlockSelectionStart to check for selectedBlockClientId
Browse files Browse the repository at this point in the history
selectedBlockClientIds() does quite a bit more work, when we only need one of the selected block ids. Generally, this will only be one block id. In the case of multiples, the previous method would get the topmost block in the selection in the array. getBlockSelectionStart gets the block where selection starts, which is a slightly different concept. Functionally, I think the outcome is identical, and getBlockSelectionStart should be faster.
  • Loading branch information
jeryj committed Feb 28, 2024
1 parent 485c05e commit 53db6c6
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ export function useHasBlockToolbar() {
const {
getBlockEditingMode,
getBlockName,
getSelectedBlockClientIds,
getBlockSelectionStart,
} = select( blockEditorStore );

const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
const selectedBlockClientId = getBlockSelectionStart();
const isDefaultEditingMode =
getBlockEditingMode( selectedBlockClientId ) === 'default';
const blockType =
Expand Down

0 comments on commit 53db6c6

Please sign in to comment.