Don't request data in WP dashboard widget when hidden
See original GitHub issueFeature 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.
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, replacinguseSelect
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
byuseInViewSelect
inassets/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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.Closing this since it’s now encompassed in #4096.