Skip to content

Commit

Permalink
RichText: fix splitValue with undefined selection (#39822)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Mar 28, 2022
1 parent f8b8da6 commit 3dddb15
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export function splitValue( {
return;
}

// Ensure the value has a selection. This might happen when trying to split
// an empty value before there was a `selectionchange` event.
const { start = 0, end = 0 } = value;
const valueWithEnsuredSelection = { ...value, start, end };
const blocks = [];
const [ before, after ] = split( value );
const [ before, after ] = split( valueWithEnsuredSelection );
const hasPastedBlocks = pastedBlocks.length > 0;
let lastPastedBlockIndex = -1;

Expand Down

0 comments on commit 3dddb15

Please sign in to comment.