Skip to content

Fix submit button when autofilling PayPal card fields#3172

Open
Crabcyborg wants to merge 7 commits into
masterfrom
paypal_autofill_submit_button_fix
Open

Fix submit button when autofilling PayPal card fields#3172
Crabcyborg wants to merge 7 commits into
masterfrom
paypal_autofill_submit_button_fix

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Related ticket https://secure.helpscout.net/conversation/3363708862/254001

This currently doesn't fully work, as the PayPal SDK treats the expiry as invalid when auto-filled.

Pre-release
formidable-6.32.3b.zip

Summary by CodeRabbit

  • Bug Fixes
    • Improved card payment form behavior when moving focus away from fields.
    • The submit button now updates correctly after a blur event, better reflecting whether card details are valid.
    • Added a small focus-handling change to preserve expected field interaction while entering payment information.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A no-op onFocus handler is added to the CardFields inputEvents configuration to preserve blur event firing. A new async onCardFieldsBlur handler is introduced that calls cardFieldsInstance.getState() on blur, updates cardFieldsValid, and conditionally enables or disables the native submit button when selectedMethod is card.

Changes

CardFields Blur Handling

Layer / File(s) Summary
onFocus no-op and onCardFieldsBlur handler
paypal/js/frontend.js
Adds an explicit no-op onFocus to inputEvents to preserve blur event compatibility, and introduces onCardFieldsBlur which calls cardFieldsInstance.getState(), updates cardFieldsValid, and enables or disables the submit button based on validity when selectedMethod === 'card'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

run analysis, run tests

Poem

🐇 Hop, hop — I blur away,
But onFocus says "no-op, stay!"
getState() reveals the truth,
Is the card valid? Here's proof!
The submit button knows the score,
Enabled or locked — nothing more. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing the submit button behavior when PayPal card fields are autofilled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 paypal_autofill_submit_button_fix

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

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

@deepsource-io

deepsource-io Bot commented Jun 24, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in b096bc4...9e3e9b5 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Jun 24, 2026 3:13p.m. Review ↗
JavaScript Jun 24, 2026 3:13p.m. Review ↗

Important

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.

Comment thread paypal/js/frontend.js Outdated
Comment on lines +774 to +775
} catch ( err ) {
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty block statement


Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed.
They can mislead the reader.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
paypal/js/frontend.js (1)

762-776: 🩺 Stability & Availability | 🔵 Trivial

CardFields blur handler can keep the silent catch intentional
cardFieldsInstance is assigned before renderCardFields() runs, so the blur handler shouldn’t see a null instance. The empty catch still hides getState() failures; add a short comment if that silence is intentional.

🤖 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 `@paypal/js/frontend.js` around lines 762 - 776, The empty catch in
onCardFieldsBlur currently swallows getState() failures without explanation.
Keep the catch if this silence is intentional, but add a brief comment inside
the catch block clarifying that errors from cardFieldsInstance.getState() are
intentionally ignored because the instance is initialized before
renderCardFields() and the blur handler should not hit a null instance.
🤖 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.

Nitpick comments:
In `@paypal/js/frontend.js`:
- Around line 762-776: The empty catch in onCardFieldsBlur currently swallows
getState() failures without explanation. Keep the catch if this silence is
intentional, but add a brief comment inside the catch block clarifying that
errors from cardFieldsInstance.getState() are intentionally ignored because the
instance is initialized before renderCardFields() and the blur handler should
not hit a null instance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 67f2190c-2db0-4949-9912-3404a7cfcfd5

📥 Commits

Reviewing files that changed from the base of the PR and between b096bc4 and 267e6c9.

📒 Files selected for processing (1)
  • paypal/js/frontend.js

Comment thread paypal/js/frontend.js
onChange: onCardFieldsChange,
// This is intentionally left blank, but it should not be deleted. onFocus is required for onBlur to work.
// eslint-disable-next-line no-empty
onFocus() {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected empty method 'onFocus'


Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant