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

Red loader at AMP menu, without validation errors #6765

Closed
fellyph opened this issue Dec 6, 2021 · 6 comments · Fixed by #6770
Closed

Red loader at AMP menu, without validation errors #6765

fellyph opened this issue Dec 6, 2021 · 6 comments · Fixed by #6770
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.
Milestone

Comments

@fellyph
Copy link
Collaborator

fellyph commented Dec 6, 2021

Bug Description

When the users switch between amp plugin sections, there is a load with a red dot when the user has no errors:

AMP.Settings.amp-beta.WordPress.mp4

Steps to reproduce:

  • At standard mode
  • Click at Settings at AMP plugin menu and Validated URLs
  • Repeat the process until see the loader

Expected Behaviour

If the users has no errors, it should not display the loader on red, because it creates a false alert

Screenshots

No response

PHP Version

7.3.5

Plugin Version

2.2 alpha

AMP plugin template mode

Standard

WordPress Version

5.8.2

Site Health

No response

Gutenberg Version

No response

OS(s) Affected

MacOS

Browser(s) Affected

Chrome 96

Device(s) Affected

No response

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

@fellyph fellyph added the Bug Something isn't working label Dec 6, 2021
@maitreyie-chavan
Copy link
Collaborator

@delawski please could you take a look at this and if reproducible, see if we can include a fix for the same in 2.2?

@westonruter
Copy link
Member

This is because the error count starts out as a spinner until the REST API request returns with the counts to display in the menu items. See #5900. So this is working as expected, but I agree it's not ideal. Should the loading indicator be removed? Or should we show the loading indicator only if on a previous page the counts returned as non-zero? We could use sessionStorage to keep track of whether a non-zero count was returned for a menu item, and if so, show the spinner. Otherwise, if no sessionStorage flag was present or the previous count was zero, then show no loading spinner. This should greatly improve the experience.

@delawski
Copy link
Collaborator

delawski commented Dec 7, 2021

I'm working on a slightly different solution.

I'm thinking of using a preload middleware for apiFetch whenever the submenu is opened. This way the number of URLs and errors would be available on page load, so there wouldn't be any loading state needed.

If the AMP menu is not expanded (so for any non-AMP related admin page), we would use the existing loading approach as implemented in #5900. I think it's justified to show a loading spinner on hover.

@westonruter
Copy link
Member

The approach taken in #5900 was to use IntersectionObserver to delay fetching the counts until we know that the user will need them. No need to make an additional HTTP request on every admin page load if the counts aren't being displayed. Therefore, I don't think preloading is best for server performance.

@delawski
Copy link
Collaborator

delawski commented Dec 7, 2021

In #6770 we preload data only if the AMP submenu is expanded, i.e. only if it's needed on page load.

In #5900 an intersection observer is not even set if the submenu is expanded. The validation counts data is fetched via HTTP request right away. That's when we see the flicker of the loading spinner needlessly.

With #6770 we still use an intersection observer for fetching the data but only if the AMP submenu is collapsed. This way we get the best of both approaches.

I guess it will become clearer once you check out #6770 and try it out live.

@delawski
Copy link
Collaborator

I've added a description to #6770 - it's now ready for review.

@westonruter westonruter modified the milestones: v2.3, v2.2 Dec 14, 2021
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants