Skip to content

Commit

Permalink
RNMobile - Check if getBlock( end ) is valid (#19239)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored and geriux committed Dec 26, 2019
1 parent 950b133 commit 296f94c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/inserter/menu.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ export default compose(

// If there a selected block,
const end = getBlockSelectionEnd();
if ( ! isAppender && end ) {
// `end` argument (id) can refer to the component which is removed
// due to pressing `undo` button, that's why we need to check
// if `getBlock( end) is valid, otherwise `null` is passed
if ( ! isAppender && end && getBlock( end ) ) {
// and the last selected block is unmodified (empty), it will be replaced
if ( isUnmodifiedDefaultBlock( getBlock( end ) ) ) {
return getBlockIndex( end, destinationRootClientId );
Expand Down

0 comments on commit 296f94c

Please sign in to comment.