site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Javascript Required Messages

Open bjackson27 opened this issue 7 years ago • 11 comments

When Javascript is disabled, Site Kit pages are blank and do not load. While WordPress' functionality is severely limited if Javascript is disabled, it would be good to at least display a message in a <noscript> tag when loading SiteKit pages that Javascript is required to use Site Kit.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When JavaScript is disabled in the browser, accessing any Site Kit admin screen (dashboard, module screens, settings), as well as the admin bar menu, should display a user-facing message: "The Site Kit by Google plugin requires JavaScript to be enabled in your browser."

Implementation Brief

  • Create a Requires_Javascript trait in the Core/Util namespace which provides a get_noscript_html method to return the <noscript> html as a string. This way we have a single source for all places we need to include the tag.
  • Add the <noscript> tag to the Screen render() method https://github.com/google/site-kit-wp/blob/b42304c5e577eb13fa5934bd9c02f2a0cba1e44b/includes/Core/Admin/Screen.php#L204-L210 which calls render_callback() from each screen to ensure the tag is included for all Site Kit screens. The tag should only be rendered if there is a render_callback
  • Add <noscript> tag to the admin bar in Admin_Bar::menu_markup()
  • Add <noscript> tag to the activation banner in Activation::get_activation_notice
  • Add CSS to hide all Site Kit loading bars (and/or app render targets) if JS is not enabled using the body.no-js class
    • Ideally something like body.no-js #js-googlesitekit-*

QA Brief

Affected areas

  • Site Kit plugin activation notice
  • Site Kit WordPress dashboard widget
  • Site Kit splash (setup) pages
  • Site Kit module dashboard pages
  • Site Kit main dashboard page
  • Site Kit settings page
  • Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics

Expected Notice when JS is disabled

The Site Kit by Google plugin requires JavaScript to be enabled in your browser.

Steps

  1. Set up Site Kit as normal with JavaScript enabled
  2. Ensure each affected area does not display the above notice that JavaScript is required
  3. Disable JavaScript
  4. Ensure each affected area does display the above notice that JavaScript is required

Changelog entry

  • Add user-facing warnings to Site Kit areas when JavaScript is disabled.

bjackson27 avatar Jul 10 '19 19:07 bjackson27

@lucymtc

Add <noscript> with message to the Screens.php admin_head existing action

This should be in a head action, it needs to be where the actual content markup is generated.

Also, the implementation brief doesn't cover the admin bar menu.

felixarntz avatar Jul 18 '19 17:07 felixarntz

@felixarntz for the admin pages it is specified to hook into admin_head I have added implementation for admin bar.

lucymtc avatar Jul 20 '19 09:07 lucymtc

@lucymtc Apologies, I originally wrote exactly the opposite of what I meant:

This ~~should~~ shouldn't be in a head action

<noscript> tags with the fallback messages should be rendered with the markup exactly where they should appear, for example in the render_callback() methods for the screen, or the Admin_Bar::menu_markup() method.

felixarntz avatar Aug 12 '19 11:08 felixarntz

Implementation brief updated

lucymtc avatar Aug 31 '19 14:08 lucymtc

Create helper in includes/Core/Util/ to return the <noscript> tag so we have a single source for any different places we need to include the tag.

Just to clarify, I think this should be implemented as a trait with a protected method, as it's quite specific (the Core/Util namespace is fine). We don't need an own class or public function for that. Other than that the IB looks solid.

felixarntz avatar Sep 02 '19 09:09 felixarntz

It's worth noting that Puppeteer has page.setJavaScriptEnabled( false ) so we should be able to write a straightforward E2E test for this one to ensure the right <noscript> content is being loaded.

tofumatt avatar Feb 10 '20 17:02 tofumatt

@felixarntz I updated the IB to include the Activation notice/app since this hadn't changed since July. I also added a point to use CSS to hide loading bars, etc using core's no-js class that wp-admin provides. Everything else is the same so I don't think this warrants a full re-review, but please take a look and let us know if there's anything else needed here 👍

aaemnnosttv avatar Feb 14 '20 18:02 aaemnnosttv

Tested

Disabled Javascript:

image

Confirmed the message is displayed:

image

Passed QA ✅

cole10up avatar Mar 11 '20 06:03 cole10up

Tested

Site Kit plugin activation notice image

Site Kit WordPress dashboard widget image

Site Kit splash (setup) pages image

Site Kit module dashboard pages image

Site Kit main dashboard page - Pass Above

Site Kit settings page image

Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics image

cole10up avatar Mar 12 '20 01:03 cole10up

Thanks for the follow up screenshots @cole10up. I think they may be out of order or missing a few though.

To clarify a few things:

  • The setup/splash page is where you land if you click Site Kit > Dashboard in the admin menu but it hasn't been set up yet. This one (you labelled as "Activation notice")
    image

    • The activation notice is what shows up immediately after activating the plugin on plugins.php
  • Site Kit splash (setup) pages
    image

    • This is totally out of our hands as it's an accounts.google.com URL.
  • Admin Bar (post edit & post on front) for posts that have data in Search Console &/or Analytics

    • Your screenshot here doesn't show that the Site Kit admin bar menu item is there. You'll need to use the developer settings plugin and match the page/post URL to one that has data on the site that you're using in the Custom Site URL. It should essentially look the same as this one from the front-end though: image
  • Site Kit WordPress dashboard widget

    • This screenshot isn't showing the WordPress dashboard 😄 (/wp-admin/index.php)

aaemnnosttv avatar Mar 12 '20 08:03 aaemnnosttv

Verified this message appears on the main dashboard, single page stats, settings page.

marrrmarrr avatar Mar 12 '20 14:03 marrrmarrr