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: Remove container assignment hack #8465

Merged
merged 1 commit into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/editor/src/components/rich-text/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ export default class TinyMCE extends Component {
return;
}

// This hack prevents TinyMCE from trying to remove the container node
// while cleaning for destroy, since removal is handled by React. It
// does so by substituting the container to be removed.
this.editor.container = document.createDocumentFragment();
this.editor.destroy();
delete this.editor;
}
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/specs/__snapshots__/rich-text.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adding blocks Should handle change in tag name gracefully 1`] = `
"<!-- wp:heading {\\"level\\":3} -->
<h3></h3>
<!-- /wp:heading -->"
`;
29 changes: 29 additions & 0 deletions test/e2e/specs/rich-text.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Internal dependencies
*/
import '../support/bootstrap';
import {
newPost,
newDesktopBrowserPage,
getEditedPostContent,
insertBlock,
} from '../support/utils';

describe( 'adding blocks', () => {
beforeEach( async () => {
await newDesktopBrowserPage();
await newPost();
} );

it( 'Should handle change in tag name gracefully', async () => {
// Regression test: The heading block changes the tag name of its
// RichText element. Historically this has been prone to breakage,
// specifically in destroying / reinitializing the TinyMCE instance.
//
// See: https://github.com/WordPress/gutenberg/issues/3091
await insertBlock( 'Heading' );
await page.click( '[aria-label="Heading 3"]' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );