-
Notifications
You must be signed in to change notification settings - Fork 92
gpalf-count-only-non-blank-rows.js: Added support to recalculate non-blank rows when a list field value changes.
#1096
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
gpalf-count-only-non-blank-rows.js: Added support to recalculate non-blank rows when a list field value changes.
#1096
Conversation
…n-blank rows when a list field value changes.
WalkthroughA jQuery document ready handler has been added to a script related to Gravity Forms list fields. This handler listens for changes on input elements within list field rows. When an input changes, it locates the associated form and, if a calculation object exists for that form, triggers recalculation of formula fields by invoking the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant GravityFormsCalc
User->>Browser: Modify input in list field row
Browser->>Browser: jQuery change event handler triggered
Browser->>GravityFormsCalc: Check if calculation object exists for form
alt Calculation object exists
Browser->>GravityFormsCalc: Call runCalcs()
GravityFormsCalc-->>Browser: Formula fields recalculated
end
Possibly related PRs
✨ 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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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-auto-list-field/gpalf-count-only-non-blank-rows.js (1)
48-65: Good addition to improve user experience with dynamic recalculation.The implementation correctly sets up an event listener to trigger formula recalculation when list field values change, addressing the core issue mentioned in the PR objective. This enhances the UX by providing immediate feedback without requiring row addition/removal.
A few observations:
- The event handler is attached to the document level, which is appropriate for dynamically added elements.
- The code includes proper defensive checks before attempting to run calculations.
- The DOM traversal logic to find the form ID is straightforward and should work reliably.
Consider adding a small comment explaining that this complements the existing filter which only triggered on row addition/removal previously.
saifsultanc
left a comment
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.
LGTM!
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/2921955434/82734
Summary
Previously, non-blank rows were recalculated only when a user added or removed a row.
This PR enhances that behaviour by also triggering recalculations when a list field value changes.
Here’s the recorded Loom
https://www.loom.com/share/c901a19a3bc1478f828dedc7a3f464f9?sid=3332c522-f652-4356-8701-37d65f32a57c