Skip to content

Commit

Permalink
Fix type error when merging blocks
Browse files Browse the repository at this point in the history
When we merge two blocks by pressing the BACKSPACE KEY, the TinyMCE
instance belonging to the second block is destroyed. This results in a
type error raised by a TinyMCE event handler that is listening to the
*same* event.

By *immediately* preventing propagation, we can stop TinyMCE's handler
from ever running.
  • Loading branch information
noisysocks committed Feb 2, 2018
1 parent a5ca791 commit 493ea9a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions blocks/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ export default class RichText extends Component {
}

event.preventDefault();

// Calling onMerge() or onRemove() will destroy the editor, so it's important
// that we stop other handlers (e.g. ones registered by TinyMCE) from
// also handling this event.
event.stopImmediatePropagation();
}

// If we click shift+Enter on inline RichTexts, we avoid creating two contenteditables
Expand Down

0 comments on commit 493ea9a

Please sign in to comment.