Skip to content

Conversation

@saifsultanc
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3059656764/88676

Summary

The Live Update snippet for GPPS is not working with Radio fields, added a case for that.

@coderabbitai
Copy link

coderabbitai bot commented Sep 4, 2025

Walkthrough

Adjusts form data serialization in GPPSLiveRefresh.refresh to only include checked radio inputs while continuing to serialize other inputs unchanged. The AJAX POST logic and method signatures remain the same.

Changes

Cohort / File(s) Summary
Form data serialization update
gp-preview-submission/gpps-live-refresh.php
Updated input loop to conditionally serialize radio inputs only when checked; non-radio inputs continue to be serialized as before. No changes to public signatures or AJAX flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • veryspry
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch saif/fix/88676-fix-radio-live-refresh

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Sep 4, 2025

Warnings
⚠️ When ready, don't forget to request reviews on this pull request from your fellow wizards.

Generated by 🚫 dangerJS against f174a05

Copy link

@coderabbitai coderabbitai bot left a 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 (2)
gp-preview-submission/gpps-live-refresh.php (2)

91-100: Also restrict checkboxes and skip unnamed controls to mirror real form posts.

Unchecked checkboxes shouldn’t be included, and elements without a name should be ignored to avoid sending a spurious "undefined" key.

Apply this minimal diff inside the loop:

-            if ( $input.is(':radio') ) {
+            if ( ! name ) {
+                return;
+            }
+
+            if ( $input.is(':radio, :checkbox') ) {
                 if ( $input.is(':checked') ) {
                     data[name] = $input.val();
                 }
             } else {
                 data[name] = $input.val();
             }

90-101: Alternative: use serialize() for fully browser-accurate encoding (radios, checkboxes, multi-select).

If you want one-liner correctness for all field types, replace the manual collection with form serialization and append the action:

var payload = self.$form.serialize() + '&action=gpps_refresh_field';
$.post( self.ajaxUrl, payload, function( response ) { /* ... */ } );

This preserves duplicate keys (e.g., multi-select) and excludes disabled/unchecked controls automatically.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ca433bf and f174a05.

📒 Files selected for processing (1)
  • gp-preview-submission/gpps-live-refresh.php (1 hunks)
🔇 Additional comments (1)
gp-preview-submission/gpps-live-refresh.php (1)

91-100: Radios: only send the checked value — good fix.

This prevents unchecked radios from clobbering the group value and aligns the payload with standard form submission semantics.

@saifsultanc saifsultanc merged commit 2999ced into master Sep 4, 2025
4 checks passed
@saifsultanc saifsultanc deleted the saif/fix/88676-fix-radio-live-refresh branch September 4, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants