Skip to content

Commit

Permalink
List: allow ENTER on multi selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jul 25, 2023
1 parent f6834cc commit a44d9e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 33 deletions.
50 changes: 22 additions & 28 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,36 +948,30 @@ export const __unstableSplitSelection =
valueA = remove( valueA, selectionA.offset, valueA.text.length );
valueB = remove( valueB, 0, selectionB.offset );

dispatch.replaceBlocks(
select.getSelectedBlockClientIds(),
[
{
// Preserve the original client ID.
...blockA,
attributes: {
...blockA.attributes,
[ selectionA.attributeKey ]: toHTMLString( {
value: valueA,
...mapRichTextSettings( attributeDefinitionA ),
} ),
},
dispatch.replaceBlocks( select.getSelectedBlockClientIds(), [
{
// Preserve the original client ID.
...blockA,
attributes: {
...blockA.attributes,
[ selectionA.attributeKey ]: toHTMLString( {
value: valueA,
...mapRichTextSettings( attributeDefinitionA ),
} ),
},
createBlock( getDefaultBlockName() ),
{
// Preserve the original client ID.
...blockB,
attributes: {
...blockB.attributes,
[ selectionB.attributeKey ]: toHTMLString( {
value: valueB,
...mapRichTextSettings( attributeDefinitionB ),
} ),
},
},
{
// Preserve the original client ID.
...blockB,
attributes: {
...blockB.attributes,
[ selectionB.attributeKey ]: toHTMLString( {
value: valueB,
...mapRichTextSettings( attributeDefinitionB ),
} ),
},
],
1, // If we don't pass the `indexToSelect` it will default to the last block.
select.getSelectedBlocksInitialCaretPosition()
);
},
] );
};

/**
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/specs/editor/various/multi-block-selection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,9 @@ test.describe( 'Multi-block selection', () => {
name: 'core/paragraph',
attributes: { content: '1' },
},
{
name: 'core/paragraph',
attributes: { content: '|' },
},
{
name: 'core/heading',
attributes: { level: 2, content: '2' },
attributes: { level: 2, content: '|2' },
},
] );
} );
Expand Down

0 comments on commit a44d9e5

Please sign in to comment.