question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't request data in WP dashboard widget when hidden

See original GitHub issue

Feature Description

When connected, Site Kit adds a widget to the WordPress dashboard which is the default landing view for all users after logging in to wp-admin. These widgets can be hidden using user-specific screen options.

image

When hidden, the Site Kit widget is still rendered (because the hiding is CSS only) so requests for data are still made. We should update our WP dashboard widget component to only request data when not hidden. Apart from the screen option, the widget could also be off screen on mobile where it may be a better experience to lazy load the data as well.


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

Acceptance criteria

  • The WP dashboard widget should use the new useInViewSelect hook from #4096 for all of its API-based selector calls, replacing useSelect for those.
  • The result should be that these API requests are only made when the WP dashboard widget is in or close to the viewport. The best way to test it is to hide the widget entirely via screen options. In that case, no API requests should be made.
    • When testing, please ensure to always clear your browser cache, since API requests are only made when nothing is cached yet.

Implementation Brief

  • When #4096 has been merged, update all use of useSelect by useInViewSelect in assets/js/components/wp-dashboard/*.js

Test Coverage

  • No new tests to be added. Existing tests that check the WP Dashboard widget output (E2E tests, mostly), may need to be updated to scroll to the WP Dashboard widget element to ensure it loads.

Visual Regression Changes

QA Brief

Changelog entry

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
felixarntzcommented, Sep 20, 2021

Moving this to “Backlog” for now, since it will depend on the useInViewportSelect (or whatever that will be called) utility that we’ll only introduce as part of the unified dashboard epic.

0reactions
felixarntzcommented, Nov 10, 2021

Closing this since it’s now encompassed in #4096.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dashboard widget gone even after 5.7.1 update - WordPress.org
Hi there @amandabandb – Try going to WooCommerce->Home and on that empty widget box top right click on the 3 dots and click...
Read more >
How to Hide Dashboard Widgets in WordPress - GreenGeeks
Dashboard widgets are a great very informative, but sometimes you may not need them. This tutorial will show you how to hide dashboard...
Read more >
How to Reposition and Hide the Dashboard Widget
Start by clicking the Screen Options button at the top right of the screen. From here, uncheck the checkbox labeled Analytics, and it...
Read more >
Hide all Dashboard Widgets (not remove)
Is there a to hide all dashboard widgets, not remove them? I want my widget to be the first widget but according to...
Read more >
How to Hide WordPress Admin Bar: Ultimate Guide - ThemeIsle
Install the “Hide Admin Bar Based on the User Roles” plugin and go to Settings → Hide Admin Bar Settings → User Roles....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found