site-kit-wp: Module settings view shows errors even after successfully saving settings
Bug Description
When I successfully submitted settings, the settings preview screen keeps showing errors that had been shown during editing settings. We should reset errors for a module when settings have been saved or changes have been canceled.
Steps to reproduce
- Go to the Google Analytics console and create a new account.
- Activate the Analytics module and connect the newly created account.
- Go to the settings page and make sure you see your selection on the settings preview screen.
- Go to the Google Analytics console again and delete the newly created account.
- Go back to the settings page and click on the “Edit” settings button.
- When the settings edit form loads, you should see errors on the form because it can’t find the deleted account (see screenshot below)
- Select another account, property, and profile and submit changes.
- Now you should see the settings preview screen, but errors from the settings edit form don’t disappear.
Screenshots
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Module store errors should be cleared after successfully saving settings
- Secondarily, module stores should not show duplicate error messages
Implementation Brief
Prevent duplicate error messages by filtering getErrors calls
- Filter errors with the exact same error message from the
StoreErrorNotices
component by adding:
const existingErrorMessages = [];
return errors
.filter( ( error ) => {
if (
! error?.message ||
existingErrorMessages.includes( error.message )
) {
return false;
}
existingErrorMessages.push( error.message );
return true;
} )
// Include other map methods in original file here…
- Clear all
modules/analytics
errors when selecting a new account. (See: 407e36905d4b21e80eb552e45ec32195857f9851) as well as when the settings screen is closed or the new settings are submitted.
Test Coverage
- N/A
Visual Regression Changes
- N/A
QA Brief
- Go to the Google Analytics console and create a new account.
- Activate the Analytics module and connect the newly created account.
- Go to the settings page and make sure you see your selection on the settings preview screen.
- Go to the Google Analytics console again and delete the newly created account.
- Go back to the settings page and click on the “Edit” settings button.
- When the settings edit form loads, you should see an error on the form because it can’t find the deleted account. You shoud only see
- Select another account, property, and profile and submit changes.
- Now you should see the settings preview screen, but errors from the settings edit form don’t disappear.
Changelog entry
- Don’t show duplicate errors when loading deleted Analytics accounts in the settings.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (1 by maintainers)
QA Update: ✅
Verified:
There is an issue that a red border remains the Analytics settings but chatting with Arafat, this needs to be a separate issue.
I’ve made a note to create a new ticket for this.
Selecting a new account doesn’t clear the fetch errors though, that’s part of the issue here—I think it’s because the errors are for various profiles/properties/etc.
When the account is selected not all errors are cleared and that’s why the message is still there… the only reliable solution I could find was to clear all errors.
@tofumatt let’s better not change the results of the
getErrors
selector and filter out duplicate errors in theStoreErrorNotices
component.We need to clear all module errors when we either close settings or before submitting the settings form.