[4.1][Bug] Google address field generates error randomly and breaks all radio fields (leaves them blank, not selected)
See original GitHub issueBug report
What I did
Have few radio fields and one google address field. Do a refresh of some page which is editing one row of a model. Every 3-5th refresh causes google object to be null. Example of page: https://webapp.com/admin/company/11/edit
What I expected to happen
I expected radio buttons to load values which are set in the database.
What happened
JS throws an error saying: Uncaught ReferenceError: google is not defined Detailed: Uncaught ReferenceError: google is not defined at bpFieldInitAddressGoogleElement (edit:1548) at HTMLInputElement.<anonymous> (edit:1627) at Function.each (bundle.js?v=4.1.20@132be56989a23fd16e0957ed40775c4fba0dfef3:2) at x.fn.init.each (bundle.js?v=4.1.20@132be56989a23fd16e0957ed40775c4fba0dfef3:2) at initializeFieldsWithJavascript (edit:1622) at HTMLDocument.<anonymous> (edit:1638) at c (bundle.js?v=4.1.20@132be56989a23fd16e0957ed40775c4fba0dfef3:2) at u (bundle.js?v=4.1.20@132be56989a23fd16e0957ed40775c4fba0dfef3:2)
What I’ve already tried to fix it
I tried looking into JS files, but didn’t find what could be the issue.
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
PHP VERSION:
PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies with Zend OPcache v7.4.9, Copyright ©, by Zend Technologies
LARAVEL VERSION:
v7.25.0@fdf3d4a40447eb286ba3820768306cae64bcc0b3
BACKPACK VERSION:
4.1.20@132be56989a23fd16e0957ed40775c4fba0dfef3
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
@azaricstefan
Thank you very much for your time and patience helping debbug this error.
I’v just submitted PR: #3180 with your solution, clearly way cleaner than mine, thanks for the tip.
Going to close this, it should be merged at most next Monday.
Wish you the best, Pedro
Hi @pxpm,
I also prefer option 2, with this check it doesn’t fail now!
if(typeof google !== "undefined") { //this is the new added line
I tested with async and I can’t reproduce it again. Thank you for detailed explanation and for the support, I appreciate it! 🍾
Can you add the check for undefined in the next update of backpack/crud?
I would also prefer to flip the condition to avoid indenting the code + it’s cleaner. 😄 Like this:
if(typeof google === "undefined") { return; }
Issue is solved, we can close it now.