Skip to content

FIX: Scope radio auto-transition to enabled fields only https://github.com/Crocoblock/issues-tracker/issues/18464#640

Open
Gawuww wants to merge 1 commit into
release/3.6.1from
issue/18464
Open

FIX: Scope radio auto-transition to enabled fields only https://github.com/Crocoblock/issues-tracker/issues/18464#640
Gawuww wants to merge 1 commit into
release/3.6.1from
issue/18464

Conversation

@Gawuww
Copy link
Copy Markdown
Collaborator

@Gawuww Gawuww commented May 11, 2026

@github-actions
Copy link
Copy Markdown

🤖 AI PR Review

Risk level: medium

Review

Summary

  • This PR scopes the automatic page transition triggered by radio inputs to only work for enabled "switch-on-change" fields and prevents attempting to advance when already on the last page.

What changed (important files)

  • modules/switch-page-on-change/assets/src/frontend/main.js
    • Adds getSwitchWrapper() and explicit checks so click handling only triggers if the radio is inside a .jet-fb-switch-page-on-change wrapper that belongs to the current page scope. Consolidates changePage() calls into a single helper.
  • modules/switch-page-on-change/assets/build/frontend.js
    • Built counterpart updated accordingly.
  • assets/src/frontend/multi.step/PageState.js
    • Early return added in PageState.changePage() if this.isLast() to avoid attempting to move past the last page.
  • assets/build/frontend/multi.step.js, other build files
    • Built assets updated to reflect source changes.

Positive notes

  • The change fixes the bug reported in the issue where radios outside of enabled switch wrappers caused automatic transitions. Scoping the handler to closest('.jet-fb-switch-page-on-change') and checking page.isNodeBelongThis(...) is the correct approach to limit the effect only to configured fields.
  • Preventing advancing from the last page is a sensible safety guard.
  • The code refactor reduces duplication (single changePage helper) and improves readability.

Security, performance, compatibility concerns

  • Security: front-end JS change only. No server-side security implications.
  • Performance: negligible. Event delegation and closest() usage are fine.
  • Backward compatibility: This is a behavior change and may affect sites that currently rely on the previous (broader) behavior where any radio could trigger a page change. In most cases this is desirable (fix), but call-out to owners:
    • If a site relied on radios outside of .jet-fb-switch-page-on-change to trigger page switching, they will no longer trigger it. Make sure all fields intended to auto-transition have the correct wrapper/class or configuration.

Potential issues and recommendations

  • Tests: There are no unit/browser tests added. Please add (or request QA) tests for the multi-step behaviour and switch-on-change module. Suggested test cases:

    • Radio inside .jet-fb-switch-page-on-change toggles page when checked (both with and without .check-mark-control).
    • Radio outside the switch wrapper does not trigger a page change.
    • Ensure jfbSync watchers still trigger changePage when the field value becomes non-empty.
    • Ensure last-page behaviour: clicking a switch on the last page should not attempt to advance or cause JS errors.
  • Edge cases to verify manually/with tests:

    • Radios nested inside the switch wrapper but where the wrapper is outside the current page scope (the new page.isNodeBelongThis check should prevent cross-page triggers).
    • Custom fields or 3rd-party integrations that may set jfbSync on non-input nodes; ensure they still behave as expected.
  • Built assets: The PR updates built assets. Ensure the build pipeline (npm/yarn) and versioning are correct and that source-to-build mapping is accurate before merge.

Minor notes

  • Files show No newline at end of file in some built assets — not critical but consider normalizing.

Overall

  • This is a targeted, low-impact fix that addresses the reported issue. Approve after adding/confirming tests and ensuring consumers are aware of the behavioral tightening (scoping to .jet-fb-switch-page-on-change).

Suggested changelog entry

- FIX: Scope radio auto-transition to enabled fields only for multi-step forms (switch-page-on-change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant