11

I've been trying to finish something and publish it online this entire weekend, it's some how broken and I have no idea why so I hope someone can help me out.

I've tried adding custom jQuery into my custom theme, with success as jQuery was loaded and the function was working. However! It wasn't functioning properly. For example Safari wouldn't load the jQuery and I kept getting these errors in my console:

defaultCaptcha.js:29 Uncaught TypeError: Cannot read property 'captcha' of undefined authentication-popup.js:26 Uncaught TypeError: Cannot read property 'autocomplete' of undefined(anonymous function)

I thought it had something to do with the way I declared my jQuery, but when that didn't seem to be the case I decided to remove all of my custom JS, and I still got these errors. Something seems to be broken further up I guess.

My Custom 'Theme' is just a simple landing page with nothing more than I custom subscription box.

What could cause these errors??

15

Replace in customer module in the file authentication-popup.js:

autocomplete: window.checkout.autocomplete

with:

autocomplete: ((window.checkout && window.checkout.autocomplete) ? window.checkout.autocomplete : null),

Once updated run

php bin/magento setup:static-content:deploy


Update

The issue may be fixed in newer versions: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js#L23

autocomplete: window.checkout.autocomplete,

was replaced with:

autocomplete: window.authenticationPopup.autocomplete,

This update is informative and does not provide the complete solution since newer Magento 2 versions come with other changes.

Here is the commit that changed into this: https://github.com/magento/magento2/commit/362f62f3c9b6c2994070615d82efbdf19f15fe50

  • We've tried this solution, and are still seeing the error present, even after running the setup:upgrade, di:compile, static-content:deploy, cache:clean and cache:flush commands. Any other suggestions? – codestr Dec 6 '17 at 17:31
  • It should go away. See if the change is in browser in the file authentication-popup.js (browser cache issue). Also see if this file is not overwritten by other file from an extension, more exactly see if the error is coming from the specified JS file or another one. – obscure Dec 7 '17 at 10:40
  • The stack trace points back to the authentication-popup.js file, and there aren't any extensions/modules overwriting it that I can find. I also thought maybe it was a cache issue, but haven't had any luck there either. I'm sure it's probably something simple I'm overlooking, I'll figure it out eventually lol. – codestr Dec 7 '17 at 14:12
  • I've tried this solution the error went away but I don't know in general how to patch, do I leave it in vendor (with a todo comment) till our next magento version update ? does anyone have a recommendation ? – medmek Nov 15 '18 at 16:16
  • 1
    @medmek You can create a git / diff patch as a fix on core files. Magento enterprise uses it here: devdocs.magento.com/guides/v2.2/cloud/project/… – obscure Nov 17 '18 at 7:32
1

After the override files from the core you have to clean static files cache (even if all caches are disabled for default mode) in order to see the effect. Never edit pub/static/frontend files because they are generated files.

0

Looks like the error is causing by the reference to autocomplete and captcha don't exist when they are supposed to. Doing what obscure did remove the error for autocomplete. I had to edit the default captcha file on .../pub/static/frontend/Magento/luma/en_US/Magento_Captcha/js/view/checkout/defaultCaptcha.js

to return null if the config it tries to reference to doesn't exist. However, that only removes the error, but the checkout page still blank.

I suspect it might have to do with the theme not falling back properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.