You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Payment field is conditionally hidden (or the section it is in is conditionally hidden), the submit button should not be disabled when Stripe Link is incomplete.
When the payment field is made visible, the submit button will be disabled if Stripe link is incomplete.
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Improved Square payment form behavior when the Square card field is conditionally hidden.
Prevented submit from being incorrectly blocked when the card field is unavailable due to form conditions.
Updated submit enablement automatically as the Square card field becomes shown or hidden.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0ef3cde3-5e68-4985-9e8e-7ed0a7edaaaf
📥 Commits
Reviewing files that changed from the base of the PR and between eb724db and 13351f6.
📒 Files selected for processing (1)
square/js/frontend.js
📝 Walkthrough
Walkthrough
Square card initialization and submission handling now account for conditionally hidden fields and sections. The frontend adds visibility checks, conditional submit-state logic, and mutation observers that resize the card and retoggle submission as visibility changes.
We reviewed changes in 057c563...13351f6 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
Filter observed attributes for better performance.
Currently, the observer is triggered by all attribute changes (e.g., class, id) and then manually filtered in handleMutation. Supplying attributeFilter: [ 'style' ] prevents the browser from emitting unnecessary mutation events, providing a performance optimization.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@square/js/frontend.js` around lines 440 - 443, Update the MutationObserver
configuration in the observer.observe call to include attributeFilter containing
only “style”, while preserving attribute observation and the existing
handleMutation processing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@square/js/frontend.js`:
- Line 414: Remove the redundant `'none' === mutation.target.display` condition
from the shouldEnable assignment in the mutation handling logic. Preserve the
existing squareCardElementIsComplete and squareIsConditionallyDisabled(form)
checks unchanged.
- Line 424: Update the mutation handling in listenForFieldMutations to guard the
cardGlobal.recalculateSize() call when cardGlobal is undefined during
initialization. Only recalculate the size once cardGlobal has been assigned,
while preserving the existing behavior after initializeCard completes.
- Around line 456-458: Update submitButtonIsConditionallyDisabled to use
optional chaining when accessing __FRMRULES[ `submit_${ formId }` ].hideDisable,
so missing global or form-specific rules safely yield an undefined property
result without throwing.
---
Nitpick comments:
In `@square/js/frontend.js`:
- Around line 440-443: Update the MutationObserver configuration in the
observer.observe call to include attributeFilter containing only “style”, while
preserving attribute observation and the existing handleMutation processing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
Push a commit to this branch (recommended)
Create a new PR with the fixes
ℹ️ Review info⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 57968a5b-1493-4983-a3aa-53aa39a1c6d9
📥 Commits
Reviewing files that changed from the base of the PR and between 057c563 and eb724db.
If a form is evaluated but __FRMRULES or the specific submit_${formId} rules object is not defined, accessing .hideDisable will throw a TypeError and crash the script. Use optional chaining to safely check for this property.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@square/js/frontend.js` around lines 456 - 458, Update
submitButtonIsConditionallyDisabled to use optional chaining when accessing
__FRMRULES[ `submit_${ formId }` ].hideDisable, so missing global or
form-specific rules safely yield an undefined property result without throwing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue https://github.com/Strategy11/formidable-pro/issues/6100
This is mostly copied from where I added the same support for Stripe Link (https://github.com/Strategy11/formidable-stripe/pull/332).
Summary by CodeRabbit
Summary by CodeRabbit