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

Add message if JavaScript is disabled #11642

Merged
merged 9 commits into from
Nov 13, 2018
Merged

Add message if JavaScript is disabled #11642

merged 9 commits into from
Nov 13, 2018

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Nov 8, 2018

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?

  • Disable Javascript using console settings
  1. Prior to change confirm the page is blank.
  2. After change you should see the message

screen shot 2018-11-08 at 11 23 34 am

Types of changes

See #2719

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

mkaz added 2 commits November 8, 2018 11:24
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' );
Copy link
Member

Choose a reason for hiding this comment

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

echo __() => _e()

Copy link
Member Author

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.

Copy link
Member Author

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>
Copy link
Member

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.

Copy link
Member Author

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.

@@ -1,4 +1,4 @@
body.is-fullscreen-mode {
Copy link
Member

Choose a reason for hiding this comment

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

See also #11677

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@youknowriad youknowriad added Needs Design Feedback Needs general design feedback. Needs Copy Review Needs review of user-facing copy (language, phrasing) labels Nov 12, 2018
@youknowriad youknowriad added this to the 4.4 milestone Nov 12, 2018
@michelleweber
Copy link

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.

Copy link
Contributor

@chrisvanpatten chrisvanpatten left a comment

Choose a reason for hiding this comment

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

Small typo!

gutenberg.php Outdated Show resolved Hide resolved
@mkaz
Copy link
Member Author

mkaz commented Nov 12, 2018

@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.

@michelleweber
Copy link

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!

@swissspidy
Copy link
Member

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
@mkaz
Copy link
Member Author

mkaz commented Nov 12, 2018

@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.

@afercia
Copy link
Contributor

afercia commented Nov 12, 2018

@mkaz thanks for working on this!

Seems it's not possible to actually click on the link because the #editor container overlays the notice 🙂

@jasmussen is printing out by default is-fullscreen-mode via PHP really necessary? I guess there are JS ways to set it before everything is rendered.

@mkaz
Copy link
Member Author

mkaz commented Nov 12, 2018

@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.

@swissspidy
Copy link
Member

What if the plugin is installed but not active?

@afercia
Copy link
Contributor

afercia commented Nov 12, 2018

The link is clickable now, thanks!

@karmatosed karmatosed self-requested a review November 12, 2018 21:50
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>
Copy link
Member

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' ),
Copy link
Member

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."

@gziolo
Copy link
Member

gziolo commented Nov 13, 2018

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?

@mcsf
Copy link
Contributor

mcsf commented Nov 13, 2018

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.

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 classic-editor query argument. In the second version, "Classic Editor plugin" links to the actual plugin.

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.

@swissspidy swissspidy changed the title Add message if Javascript is disabled Add message if JavaScript is disabled Nov 13, 2018
Two different messages if trying to access block editor via the
plugin or via core.
@mkaz
Copy link
Member Author

mkaz commented Nov 13, 2018

@mcsf @gziolo - I've updated based on your suggestions.

@gziolo
Copy link
Member

gziolo commented Nov 13, 2018

Thanks @mkaz for updating 👍

gutenberg.php Outdated Show resolved Hide resolved
@mkaz
Copy link
Member Author

mkaz commented Nov 13, 2018

@chrisvanpatten can I get your ✅ on the resolved typo? Thanks!

@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented Nov 13, 2018

@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 :)

@mkaz mkaz merged commit ee51293 into master Nov 13, 2018
@mkaz
Copy link
Member Author

mkaz commented Nov 13, 2018

Thanks @chrisvanpatten I marked as resolved too, I do think it's a Github bug.

@mkaz mkaz deleted the fix/2719/no-javascript branch November 13, 2018 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Copy Review Needs review of user-facing copy (language, phrasing) Needs Design Feedback Needs general design feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants