Skip to content

Commit

Permalink
Only select block if there isn't any already
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed May 11, 2023
1 parent 0142fc1 commit 0dc67e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function ListViewBlock( {
},
[ isContentLocked, clientId, isSelected ]
);
const { getSelectedBlockClientIds } = useSelect( blockEditorStore );

const canExpand = isContentLocked ? false : canEdit;
const isFirstSelectedBlock =
Expand Down Expand Up @@ -175,7 +176,11 @@ function ListViewBlock( {

const updateSelection = useCallback(
( newClientId ) => {
selectBlock( undefined, newClientId, null, null );
const selectedBlockClientIds = getSelectedBlockClientIds();
// Select the block to be focused if there isn't any block selected.
if ( ! selectedBlockClientIds.length ) {
selectBlock( undefined, newClientId, null, null );
}

const getFocusElement = () => {
const row = treeGridElementRef.current?.querySelector(
Expand Down

0 comments on commit 0dc67e8

Please sign in to comment.