site-kit-wp: Show spinner when saving, unsaving, or dismissing an idea in Idea Hub widget
There can be a delay when clicking one of the Idea Hub widget icon buttons to save, unsave, or dismiss an idea. This delay is expected due to sending the API request, however we should cater for this in the UI by showing a loading indicator.
See https://app.asana.com/0/1200491083500938/1200758448284506/f
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- When clicking on one of the icon buttons to “Save”, “Dismiss” (both in the “New” tab) or “Unsave” (in the “Saved” tab) an idea, the respective icon should be replaced by a loading spinner until the action has been completed.
- Whenever that spinner is displayed, the “overlay” with the idea interaction buttons for that respective idea should be “permanently” displayed as long as the spinner is there / as long as the process/API request takes.
- In other words, when hovering/focusing away from the idea while one of the interactions is in progress, the overlay shouldn’t disappear like it usually does when there’s no action in progress. This can be accomplished for example by conditionally applying an extra CSS class on the overlay wrapper.
Additional Acceptance criteria
See https://github.com/google/site-kit-wp/issues/3907#issuecomment-989000016.
- All 4 actions should have the loading spinner.
- All 4 actions should have a brief success state where they show a brief message that remains there for a brief period before the idea disappears (from the current tab) - basically this should work the same way it already does for creating a draft.
- The success messages should be:
- Idea saved
- Idea dismissed
- Idea removed from saved
- Draft created (already exists)
Implementation Brief
- Inside
assets/js/modules/idea-hub/datastore/constants.js:- Add the following new activity constants:
IDEA_HUB_ACTIVITY_IS_DELETINGIDEA_HUB_ACTIVITY_IS_PINNINGIDEA_HUB_ACTIVITY_IS_UNPINNING
- Remove
IDEA_HUB_ACTIVITY_IS_PROCESSING
- Inside
assets/js/modules/idea-hub/components/dashboard/DashboardIdeasWidget/Idea.js- Import the new constants, and remove the import of
IDEA_HUB_ACTIVITY_IS_PROCESSING - Inside the
handleDelete,handlePinandhandleUnpincallbacks, replaceIDEA_HUB_ACTIVITY_IS_PROCESSINGwith the corresponding activity constant, soIDEA_HUB_ACTIVITY_IS_DELETINGinsidehandleDeleteetc. - Add the
.googlesitekit-idea-hub__idea--is-processingclass name to the.googlesitekit-idea-hub__idea--singlewrapper if there is an activity in progress. - For each of the
IDEA_HUB_BUTTON_DELETE,IDEA_HUB_BUTTON_PINandIDEA_HUB_BUTTON_UNPINbuttons, passCircularProgresswithsizeset to24as prop, as the value for theiconprop if the corresponding activity constant is truthy. So ifIDEA_HUB_ACTIVITY_IS_DELETINGis truthy, passCircularProgress; if not, pass the appropriate existing icon. - Replace the remaining logic that uses
IDEA_HUB_ACTIVITY_IS_PROCESSINGto set thedisabledattributes on the create and view buttons with a check to see ifactivityis truthy. In other words, disable the buttons if there is anactivityin progress.
- Import the new constants, and remove the import of
- Using
assets/sass/components/idea-hub/_googlesitekit-idea-hub-dashboard-ideas-widget.scss,- Update
.googlesitekit-idea-hub__idea--actions svgto exlude the.MuiCircularProgress-svgso that we are not setting any styles on theCircularProgresssvg. - Add styles for
.googlesitekit-idea-hub__idea--is-processingwhich are similar to.googlesitekit-idea-hub__idea--single:hoverand..googlesitekit-idea-hub__idea--single:focuswhere the icons are visible except the background color is white.
- Update
Test Coverage
- No new tests should be required.
Visual Regression Changes
- VRT images dealing with the DashboardIdeaWidget UI might need updating.
QA Brief
- Setup the Idea Hub module.
- Upon interacting with an idea, i.e pinning, unpinning, deleting or creating an idea, there should be a loading icon when activity is in progress.
Changelog entry
- Update the Idea Hub widget to display a spinner when saving, unsaving or dismissing an idea.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (11 by maintainers)
@asvinb @aaemnnosttv After discussing this with @marrrmarrr, let’s go with my suggestion 1. in https://github.com/google/site-kit-wp/issues/3907#issuecomment-987039245:
@felixarntz @aaemnnosttv Just FYI, we have #3902 which relates to what we are trying to do. Maybe we can create a follow up issue which is blocked by #3902 or look into Material’s snack bar.
@asvinb Great question. I definitely agree that we should make the user experience consistent between all 4 actions, and I think the spinner should be on all 4 of them. However, there is also the part of briefly showing a “success” message on the idea which we currently have for creating drafts but not the other 4.
With your current PR #4444 the experience is as follows:
I think we should do one of the following to make the experience consistent:
I’d vote for 1., mainly because the success indicator also allows the idea to not immediately “disappear”. @marrrmarrr @samitron7 What do you think?
@johnPhillips Actually we can solve the issue about the hover state by adding another class name to the container having
googlesitekit-idea-hub__idea--singleas class, for e.ggooglesitekit-idea-hub__idea--is-processingwhenactivityis not null, and in the corresponding styles, we make sure the buttons are displayed irrespective of breakpoints and hover state. So whengooglesitekit-idea-hub__idea--is-processingis present, the idea has the same styles as uponhover. Let me know what you think.