-
Notifications
You must be signed in to change notification settings - Fork 91
gppa-populate-child-entries.php
: Fixed field does not populate on first load issue.
#1090
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
base: master
Are you sure you want to change the base?
Conversation
…irst load issue.
WalkthroughThe update modifies the JavaScript logic within the Changes
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
gp-populate-anything/gppa-populate-child-entries.php (1)
135-141
: Great fix for the cookie null check.The added condition
&& gpnfCookie
ensures that the code won't attempt to access thehash
property of a potentially undefined or null cookie object. This defensive programming approach prevents JavaScript errors during initial page load when the cookie might not be available yet, fixing the issue where the field doesn't populate on first load.For even more robust error handling, you could consider:
- if ( ! self.$peidField.val() && gpnfCookie ) { + if ( ! self.$peidField.val() && gpnfCookie && typeof gpnfCookie.hash !== 'undefined' ) {This additional check ensures the
hash
property exists before attempting to use it, though your current fix should handle the reported issue completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to fully work as desired.
I made a loom explaining:
https://www.loom.com/share/f99ef6460860410691832455d7037475
Lmk!
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2917938488/82554
Summary
Due to some JS error in console, field doesn't populate on first load. If we reload the page, it populates.
Here's the loom recording of this issue. This PR fixes this issue.
https://www.loom.com/share/7fc577ae7c274ec48df5a1b3c36fe995?sid=26c1e9f0-ec10-473e-b6e7-bad4622b9ed8