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

Tag Manager stuck in loading state when reloading edit settings page. #6464

Closed
techanvil opened this issue Jan 26, 2023 · 3 comments
Closed
Labels
Exp: SP Module: Tag Manager Google Tag Manager module related issues P0 High priority Type: Bug Something isn't working

Comments

@techanvil
Copy link
Collaborator

techanvil commented Jan 26, 2023

Bug Description

When editing the Tag Manager settings, upon reloading the page, the Tag Manager section remains in the loading state.

This is because, for some reason, the Tag Manager's ownerID is not being set and this causes the hasModuleOwnershipOrAccess selector to return undefined. This in turn is a condition for showing the <ProgressBar />.

Note, I also checked this scenario for Analytics but the problem did not occur.

Steps to reproduce

  1. Set up Site Kit and connect the Tag Manager module.
  2. Navigate to the Tag Manager settings and click Edit.
  3. Refresh the page.
  4. See the Tag Manager section open and stuck in the loading state.

Screenshots

image.png

Additional Context

  • PHP Version: any
  • OS: any
  • Browser: any
  • Plugin Version: seen 1.92.0
  • Device: any

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When reloading the Tag Manager edit settings page, it should load normally and not remain stuck in the loading state.

Implementation Brief

  • In useGAPropertyIDEffect()
    export default function useGAPropertyIDEffect() {
    • Load tagmanager settings select( MODULES_TAGMANAGER ).getSettings()
    • In the useEffect only call the setGAPropertyID() function if the tagmanger settings are not falsy.
      useEffect( () => {
      	if ( !! existingSettings && singleAnalyticsPropertyID !== undefined ) {
      		setGAPropertyID( singleAnalyticsPropertyID || '' );

Test Coverage

  • Update failing test which not need tagmanager setting setup.
  • Add a test case to useGAPropertyIDEffect.test.js to verify setGAPropertyID is not called when select( MODULES_TAGMANAGER ).getSettings() is falsy.

QA Brief

  • Follow the "Steps to reproduce" from bug description above.
  • Verify the tagmanager settings are not stuck in loading state anymore but load the input fields as expected.

Changelog entry

  • Fix bug that caused Tag Manager settings screen to be stuck in a "loading" state.
@techanvil techanvil added Module: Tag Manager Google Tag Manager module related issues P0 High priority Type: Bug Something isn't working labels Jan 26, 2023
@derweili derweili self-assigned this Jan 27, 2023
@derweili
Copy link
Collaborator

The error is related to the SettingsEdit component loading the useExistingTagEffect side effect (here)

export default function useGAPropertyIDEffect() {
const singleAnalyticsPropertyID = useSelect( ( select ) =>
select( MODULES_TAGMANAGER ).getSingleAnalyticsPropertyID()
);
const { setGAPropertyID } = useDispatch( MODULES_TAGMANAGER );
useEffect( () => {
if ( singleAnalyticsPropertyID !== undefined ) {
setGAPropertyID( singleAnalyticsPropertyID || '' );
}
}, [ singleAnalyticsPropertyID, setGAPropertyID ] );
}

This side effect triggers an update to the tagmanager datastore which at that time is still empty.

Because other functions which normally would trigger the fetchGetSettings() action are executed after the side effect, the settings are not empty anymore, so the *getSettings() resolver does not call the fetchGetSettings().

*getSettings() {
const registry = yield Data.commonActions.getRegistry();
const existingSettings = registry
.select( STORE_NAME )
.getSettings();
// If settings are already present, don't fetch them.
if ( ! existingSettings ) {
yield fetchGetSettingsStore.actions.fetchGetSettings();
}
},
};

Therefore the useExistingTagEffect() hook should be update to only call setGAPropertyID() if getSettings() is not falsy.

@derweili derweili removed their assignment Jan 30, 2023
@eugene-manuilov eugene-manuilov self-assigned this Jan 30, 2023
@eugene-manuilov
Copy link
Collaborator

IB ✔️

@eugene-manuilov eugene-manuilov removed their assignment Jan 30, 2023
@derweili derweili self-assigned this Feb 2, 2023
@derweili derweili removed their assignment Feb 3, 2023
@jimmymadon jimmymadon assigned jimmymadon and unassigned jimmymadon Feb 5, 2023
@tofumatt tofumatt assigned tofumatt and derweili and unassigned tofumatt Feb 7, 2023
@derweili derweili assigned tofumatt and unassigned derweili Feb 7, 2023
@tofumatt tofumatt removed their assignment Feb 7, 2023
@wpdarren wpdarren self-assigned this Feb 8, 2023
@wpdarren
Copy link
Collaborator

wpdarren commented Feb 8, 2023

QA Update: ✅

@techanvil this is a great find!

@mohitwp this is a good one to make a note of for when release testing. I'll add a test case for refreshing all settings.

Verified:

  • Went through the the steps to reproduce on the latest version, and could.
  • Changed to develop branch and on refresh the loading state does not get stuck anymore.
tm-settings.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Exp: SP Module: Tag Manager Google Tag Manager module related issues P0 High priority Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants