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

Only load Gutenberg Polyfill in Gutenberg pages #6849

Merged
merged 1 commit into from
May 21, 2018
Merged

Conversation

youknowriad
Copy link
Contributor

This PR fixes #6847 by avoiding to load the Gutenberg scripts in the classic editor.
This avoids any TinyMCE conflict.

I also added an e2e test to avoid this kind of regressions in the future.

@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label May 19, 2018
@youknowriad youknowriad self-assigned this May 19, 2018
@youknowriad youknowriad requested review from pento and a team May 19, 2018 22:57
@gziolo
Copy link
Member

gziolo commented May 21, 2018

It seems like a legit fix, however, I'd prefer to have someone else double check PHP logic.


if ( ! gutenberg_can_edit_post( $post ) ) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be handy to define a is_editor_page function to check whether we're loading a Gutenberg page or not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, maybe some logic can be shared with pieces of gutenberg_init? Not sure if anything should be different there. It doesn't have the admin and post checks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I don't really understand why it has these checks here, and gutenberg_init does not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gutenberg/gutenberg.php

Lines 153 to 159 in 70e9e4f

if ( isset( $_GET['classic-editor'] ) ) {
return false;
}
if ( ! gutenberg_can_edit_post( $post ) ) {
return false;
}

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the issue for me. Would be nice to either share the logic with gutenberg_init or explain why different checks are needed. Would also be nice to explain why this is needed: "Ensure the editor module is loaded before third party plugins."

@youknowriad
Copy link
Contributor Author

"Ensure the editor module is loaded before third party plugins."

This is needed before the previous APIs defined in wp-blocks are loaded in wp-editor and wp-editor is not added as a dependency to these third party plugins. We have a warning showing on the console to help plugin authors migrate but during that period we need to load wp-editor before everything else to avoid breakage.

@youknowriad
Copy link
Contributor Author

gutenberg_init or explain why different checks are needed

The checks are not different. This has an extra check to ensure we're on the editor page get_current_screen. The gutenberg_init is only run in the replace_editor hook or in post.php

@youknowriad
Copy link
Contributor Author

Merging as this fixed the issue and it's a temporary polyfill anyway.

@youknowriad youknowriad merged commit 6453eb5 into master May 21, 2018
@youknowriad youknowriad deleted the fix/polyfill branch May 21, 2018 11:51
@mtias mtias added this to the 3.0 milestone Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Classic Editor Visual Mode Broken by Gutenberg
4 participants