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

TypeError: Cannot read properties of undefined (reading 'template_options') #641

Open
cviebrock opened this issue Apr 2, 2024 · 2 comments

Comments

@cviebrock
Copy link

After recently upgrading a site from Drupal 9 to 10, and this package from 2.9.1645644008 to 3.5.1709296836, we're having issues with editing mailings. Specifically, when you click on the "TEST" button to send a test email, the modal pops up, but none of the form elements on the modal are clickable: the preview buttons aren't clickable, I can't change the test email destination, nor click on the Send test button).

When the modal opens, I get the following error in Chrome dev tools in the following file https://example.ca/sites/default/files/civicrm/persist/contribute/dyn/angular-modules.8d867be56648f37143ace17e16449636.js

angular-modules.8d867be56648f37143ace17e16449636.js:3651  TypeError: Cannot read properties of undefined (reading 'template_options')
    at b.isSplit (angular-modules.8d867be56648f37143ace17e16449636.js:4227:22)
    at fn (eval at compile (angular.js:16548:15), <anonymous>:4:217)
    at m.$digest (angular.js:19262:34)
    at m.$apply (angular.js:19630:13)
    at cmd.execute (angular-modules.8d867be56648f37143ace17e16449636.js:3651:24)
    at HTMLAnchorElement.<anonymous> (knockout-latest.js:100:264)
    at HTMLAnchorElement.dispatch (jquery.js:5135:27)
    at p.handle (jquery.js:4939:28)
(anonymous) @ angular.js:15697
(anonymous) @ angular.js:11956
$digest @ angular.js:19288
$apply @ angular.js:19630
cmd.execute @ angular-modules.8d867be56648f37143ace17e16449636.js:3651
(anonymous) @ knockout-latest.js:100
dispatch @ jquery.js:5135
p.handle @ jquery.js:4939

Any ideas what's happening? I'm not sure this is an issue with my install, or the upgrade, or if I missed a step.

@cviebrock
Copy link
Author

Quick follow-up: I've tried installing earlier versions of the extension from the latest 3.5 all the way back to 2.11. I don't see the above error message in 3.4 and before, but all the controls in the modal are still disabled and unclickable.

@cviebrock
Copy link
Author

cviebrock commented Apr 3, 2024

Further follow-ups:

  1. I can tab through the fields in the modal and update the test email field, for example, but using the cursor to click on things doesn't work.
  2. I think the issue can be traced back to this function in ang/crmMosaico/Variants.js:
      // isSplit(mailing): Determine if there are -any- split/variant fields.
      // isSplit(mailing, field): Determine if a -specific- field has variations.
      isSplit: function isSplit(mailing, field) {
        if (!mailing.template_options || !mailing.template_options.variants) {
          return false;
        }
        if (field) {
          return (field in mailing.template_options.variants[0]);
        }
        const nonEmpties = _.filter(mailing.template_options.variants, (v) => !_.isEmpty(angularObj(v)));
        return nonEmpties.length > 0;
      }

For some reason that function is called with mailing being undefined, and then it barfs. I'm not sure if it's as simple as adding a check for that in the function itself, or if something else is happening upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant