Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyMCE error when merging two paragraph blocks #4580

Closed
aduth opened this issue Jan 18, 2018 · 0 comments · Fixed by #4791
Closed

TinyMCE error when merging two paragraph blocks #4580

aduth opened this issue Jan 18, 2018 · 0 comments · Fixed by #4791
Assignees
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Milestone

Comments

@aduth
Copy link
Member

aduth commented Jan 18, 2018

Issue Overview

When merging two paragraph blocks using backspace, an error is logged to the console. This does not appear to have user-impacting implications.

Steps to Reproduce (for bugs)

  1. Navigate to Posts > New Post
  2. Create two paragraph blocks
  3. Place cursor at beginning of second paragraph block
  4. Press Backspace

Expected Behavior

The two blocks are merged, and no error is logged.

Current Behavior

The two blocks are merged, but an error is logged:

Uncaught TypeError: Cannot read property 'startContainer' of null
    at Selection.getStart (tinymce.68215e08.js:29069)
    at removeCaretContainer (tinymce.68215e08.js:20275)
    at disableCaretContainer (tinymce.68215e08.js:20447)
    at Editor.<anonymous> (tinymce.68215e08.js:20473)
    at Dispatcher.fire (tinymce.68215e08.js:23089)
    at Editor.fire (tinymce.68215e08.js:23329)
    at DOMUtils.delegate (tinymce.68215e08.js:23534)
    at executeHandlers (tinymce.68215e08.js:1694)
    at HTMLParagraphElement.defaultNativeHandler (tinymce.68215e08.js:1721)

Offending line of code:

https://github.com/tinymce/tinymce/blob/1c05b6686632fca6d7ffb3983febbbcbd740efd5/src/core/main/ts/dom/Selection.ts#L145

Possible Solution

It appears that despite the instance being destroyed in the TinyMCE component's componentWillUnmount, an event callback for the keydown event is still being fired after removal.

Some possible reasons to explore:

  • An asynchronous timeout is scheduled prior to the destroy, and there is no condition to check that the editor still exists after the delay elapses
  • Events are not being unbound during the destroy process
@aduth aduth added [Type] Bug An existing feature does not function as intended [Component] TinyMCE labels Jan 18, 2018
@mtias mtias added the [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... label Jan 18, 2018
@karmatosed karmatosed modified the milestone: Merge Proposal Jan 25, 2018
@noisysocks noisysocks self-assigned this Feb 1, 2018
andrewserong added a commit to andrewserong/gutenberg that referenced this issue Feb 13, 2019
… instead of heading (WordPress#10326)

The onSplit method for the heading block will now replace an empty heading block with an empty paragraph block for the 'before' content.

This allows the ENTER key pressed at the beginning of a heading to create an empty paragraph above it. Also, when the ENTER key is pressed at the end of a heading, an empty paragraph block is created below, instead of another heading block. The RichText component now also calls event.stopImmediatePropagation() before splitContent() to prevent TinyMCE from throwing an error. This avoids a similar error as in WordPress#4580.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants