profile
viewpoint

Ask questionsModule 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

<!-- Please provide detailed steps on how to reproduce the bug. -->

  1. Go to the Google Analytics console and create a new account.
  2. Activate the Analytics module and connect the newly created account.
  3. Go to the settings page and make sure you see your selection on the settings preview screen.
  4. Go to the Google Analytics console again and delete the newly created account.
  5. Go back to the settings page and click on the "Edit" settings button.
  6. When the settings edit form loads, you should see errors on the form because it can't find the deleted account (see screenshot below)
  7. Select another account, property, and profile and submit changes.
  8. Now you should see the settings preview screen, but errors from the settings edit form don't disappear.

Screenshots

sitekit 10uplabs com_wp-admin_admin php_page=googlesitekit-settings


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

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

  1. Go to the Google Analytics console and create a new account.
  2. Activate the Analytics module and connect the newly created account.
  3. Go to the settings page and make sure you see your selection on the settings preview screen.
  4. Go to the Google Analytics console again and delete the newly created account.
  5. Go back to the settings page and click on the "Edit" settings button.
  6. 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
  7. Select another account, property, and profile and submit changes.
  8. 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.
google/site-kit-wp

Answer questions kuasha420

@wpdarren that seems to be the case. The red border appears when it's asking for additional permission, which should go away once permission is granted. Should be a separate issue.

useful!
source:https://uonfu.com/
answerer
Arafat Zahan kuasha420 @10up Dhaka, Bangladesh kuasha.xyz Senior JavaScript Engineer @10up.
Github User Rank List