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
The JS to sync which setting is visible misses this case and ends up displaying both the Stripe and Square settings.
To replicate
Create a payment action. Set it to One Time, Square.
Change to Stripe.
Change to Recurring.
When testing
We'll want to test with the Stripe add-on active, and inactive, is these may work differently.
It's also good to test Authorize.Net active and inactive, as the gateways use checkboxes when Authorize.Net is available. While you shouldn't have both Stripe and Square selected (it won't really work), both settings should appear if both gateways are selected.
Before
Screen.Recording.2026-05-08.at.1.07.00.PM.mov
After
Screen.Recording.2026-05-08.at.1.08.24.PM.mov
Summary by CodeRabbit
Refactor
Improved payment gateway settings visibility so sub-options consistently show or hide based on transaction type (recurring vs. one-time) and selected gateways.
Ensures layout for gateway sub-option groups remains intact when displayed.
Fixes cases where repeat-cadence controls could remain hidden after being added, improving UI reliability.
Extracts repeated sub-option visibility logic into updateGatewaySettingsVisibility(settings) and updates onGatewayToggle, onToggleSub, and syncRepeat to call this helper; ensures grid containers keep display:grid and newly inserted cadence wrappers remove frm_hidden.
Changes
Gateway Settings Visibility Refactor
Layer / File(s)
Summary
Core Visibility Helper square/js/action.js
Introduces updateGatewaySettingsVisibility(settings) that centralizes .frm_trans_sub_opts visibility control by checking active transaction type and gateway, then toggling frm_hidden class and style.display for each sub-option container. Non-recurring types hide all sub-options.
Event Handler Integration square/js/action.js
onGatewayToggle calls the helper after syncing repeat/currency. onToggleSub calls the helper inside its setTimeout. syncRepeat removes frm_hidden from the newly created repeat-cadence wrapper's closest .frm_trans_sub_opts.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
🐰 A little rabbit hops through code so sly,
One helper gathers toggles under sky.
Grids stay tidy, hidden bits retreat,
Gateways and repeats now dance in beat.
🎩✨
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
⚠️ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title 'Update gateway setting toggle logic' directly corresponds to the main change: refactoring gateway visibility toggle logic to prevent duplicate recurrence settings from displaying across different gateways (Stripe vs Square).
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches📝 Generate docstrings
Create stacked PR
Commit on current branch
🧪 Generate unit tests (beta)
Create PR with unit tests
Commit unit tests in branch update_gateway_setting_toggle_logic
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.
We reviewed changes in f42ed06...1b61848 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.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 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/action.js`:
- Around line 25-29: The show-paths in updateGatewaySettingsVisibility (and the
similar blocks around the other two occurrences) remove the frm_hidden class but
do not clear inline style.display, so elements hidden earlier with style.display
= 'none' remain invisible; update the show logic that handles subOpts (and the
two analogous blocks) to set subOpts.style.display = 'grid' when
subOpts.classList.contains('frm_grid_container') and otherwise reset
subOpts.style.display = '' (or an appropriate default like 'block') so
visibility is fully restored after toggles.
- Line 23: The expression using string concatenation in the contains check for
hasActiveGatewayClass should use a template literal to satisfy
eslint(prefer-template); update the call to subOpts.classList.contains(...) in
the hasActiveGatewayClass assignment to use a template literal like
`show_${activeGateway}` instead of `'show_' + activeGateway` so the variable
hasActiveGatewayClass is computed with the template form.
🪄 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: f1031a66-9ff6-424e-8fe7-41934a3e15d0
📥 Commits
Reviewing files that changed from the base of the PR and between f42ed06 and a18ae98.
‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
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/action.js` at line 23, The expression using string concatenation in
the contains check for hasActiveGatewayClass should use a template literal to
satisfy eslint(prefer-template); update the call to
subOpts.classList.contains(...) in the hasActiveGatewayClass assignment to use a
template literal like `show_${activeGateway}` instead of `'show_' +
activeGateway` so the variable hasActiveGatewayClass is computed with the
template form.
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Potential issue | 🟠 Major | ⚡ Quick win
Visible sub-options can stay hidden after mode/gateway switches
updateGatewaySettingsVisibility hides elements via inline style.display = 'none' (Line 55-56), but in the show paths it does not reset style.display for non-grid containers. After toggling away and back, those rows can remain hidden even after removing frm_hidden.
💡 Suggested fix
- if ( hasActiveGatewayClass ) {- subOpts.classList.remove( 'frm_hidden' );- if ( subOpts.classList.contains( 'frm_grid_container' ) ) {- subOpts.style.display = 'grid';- }+ if ( hasActiveGatewayClass ) {+ subOpts.classList.remove( 'frm_hidden' );+ subOpts.style.display = subOpts.classList.contains( 'frm_grid_container' ) ? 'grid' : '';
} else {
@@
- } else {- // Show if it has no show_* class (shared setting)- subOpts.classList.remove( 'frm_hidden' );- if ( subOpts.classList.contains( 'frm_grid_container' ) ) {- subOpts.style.display = 'grid';- }+ } else {+ // Show if it has no show_* class (shared setting)+ subOpts.classList.remove( 'frm_hidden' );+ subOpts.style.display = subOpts.classList.contains( 'frm_grid_container' ) ? 'grid' : '';
}
}
Also applies to: 42-45, 55-56
🤖 Prompt for 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.
In `@square/js/action.js` around lines 25 - 29, The show-paths in
updateGatewaySettingsVisibility (and the similar blocks around the other two
occurrences) remove the frm_hidden class but do not clear inline style.display,
so elements hidden earlier with style.display = 'none' remain invisible; update
the show logic that handles subOpts (and the two analogous blocks) to set
subOpts.style.display = 'grid' when
subOpts.classList.contains('frm_grid_container') and otherwise reset
subOpts.style.display = '' (or an appropriate default like 'block') so
visibility is fully restored after toggles.
The reason will be displayed to describe this comment to others. Learn more.
Unexpected string concatenation
In ES2015 (ES6), we can use template literals instead of string concatenation.
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.
This update should prevent this issue where "Repeat" appears twice.
The problem
To replicate
When testing
Before
Screen.Recording.2026-05-08.at.1.07.00.PM.mov
After
Screen.Recording.2026-05-08.at.1.08.24.PM.mov
Summary by CodeRabbit