-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add message if JavaScript is disabled #11642
Conversation
Adds a noscript and message if Javascript is disabled. This also required adding a :not(.no-js) to the fullscreen body class which hides/shows the rest of the wp-admin chrome.
gutenberg.php
Outdated
<noscript> | ||
<div class="error" style='margin-top:32px'><p> | ||
<?php | ||
echo __( 'The block editor requires Javascript to be enabled.', 'gutenberg' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo __()
=> _e()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The echo __()
function is used in numerous spots in gutenberg.php, I just mirrored it to stay consistent within the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs down is not really a productive response.
I've switched each of the occurrences to the shorter function.
gutenberg.php
Outdated
@@ -29,6 +29,13 @@ function the_gutenberg_project() { | |||
global $post_type_object; | |||
?> | |||
<div class="block-editor gutenberg"> | |||
<noscript> | |||
<div class="error" style='margin-top:32px'><p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admin bar has different heights depending on the viewport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The margin was simply to give some spacing from the bottom of the admin bar, so the error message isn't squished up against the top.
97b86bc
to
4074ceb
Compare
@@ -1,4 +1,4 @@ | |||
body.is-fullscreen-mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also #11677
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I always like to give a specific next step in an error message when possible. In this case, that would be something like "The Block Editor requires Javascript. Go to your browser's settings and enable Javascript before using it. Learn more." Ideally the "learn more" is a link to instructions re: how to enable JS, but if we don't have that, just delete it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo!
@michelleweber I've updated with your change, but after revisiting the bug, I think the suggestion here by @afercia might be better, adding a to link to the Classic Editor plugin The user probably either has JavaScript disabled on purpose, or it not supported by their device, so the plugin instructions might be more helpful. |
Works for me. As long as we give the user some kind of next step, we're good -- I leave it to you to decide what the actual best next step is! |
I know this is now getting a bit more complex, but can we add some more conditions whether the Classic Editor plugin is already installed and whether it's active? Perhaps also whether the user has the capability to install it. At least a direct link to the classic editor if the plugin is already active would be nice. |
Add position absolute and higher z-index to make link clickable. The block-editor pane was positioned above the inserted link. h/t @georgehotelling
@swissspidy I know, so much effort on a rare edge case, but might as well do it properly. I did consider that about if the plugin is installed, however the user should not get to this page since it is a Gutenberg page and if the plugin is installed they will go straight to the Classic Editor. I also just had to push up some CSS z-index positioning stuff to make it clickable, no such thing as a quick fix. |
@mkaz thanks for working on this! Seems it's not possible to actually click on the link because the @jasmussen is printing out by default |
@afercia can you make sure you are updated to the latest PR, I just pushed up a fix to address the issue of it being clickable. Also, just updated with your CSS suggestion. |
What if the plugin is installed but not active? |
The link is clickable now, thanks! |
gutenberg.php
Outdated
@@ -28,6 +28,16 @@ | |||
function the_gutenberg_project() { | |||
global $post_type_object; | |||
?> | |||
<noscript> | |||
<div class="error" style='position:absolute;top:32px;z-index:40'><p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use single quotes for the style attribute?
gutenberg.php
Outdated
<div class="error" style='position:absolute;top:32px;z-index:40'><p> | ||
<?php | ||
printf( | ||
__( 'The Block Editor requires JavaScript, please try the <a href="%s">Classic Editor plugin</a>.', 'gutenberg' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will read better as two sentences.
"The Block Editor requires JavaScript. Please try the Classic Editor plugin."
I think that this message is valid in the context of WordPress core. I'm not convinced that it is the way to go when Gutenberg plugin is activated. @mcsf @youknowriad @mtias do you agree? |
Yeah. Might be behind a conditional: if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
// The Block Editor requires JavaScript. Please enable JavaScript or use the Classic Editor.
} else {
// The Block Editor requires JavaScript. Please try the Classic Editor plugin.
} In the first version, "Classic Editor" links to the current URL with an extra I don't feel strongly about keeping the "enable JavaScript" fragment, but it seems fair to ask for this if a user went to the trouble of installing the Gutenberg plugin. |
Two different messages if trying to access block editor via the plugin or via core.
Thanks @mkaz for updating 👍 |
@chrisvanpatten can I get your ✅ on the resolved typo? Thanks! |
@mkaz Oh sorry, I thought my review would have been auto-dismissed after you incorporated my suggestion. Get that fixed up, GitHub! Approving in a sec :) |
Thanks @chrisvanpatten I marked as resolved too, I do think it's a Github bug. |
Description
Adds a noscript and message if Javascript is disabled.
This also required adding a :not(.no-js) to the fullscreen body class
which hides/shows the rest of the wp-admin chrome.
How has this been tested?
Types of changes
See #2719
Checklist: