Skip to content

Try to enable submit button on safari autofill#3170

Closed
Crabcyborg wants to merge 3 commits into
masterfrom
try_to_enable_submit_button_on_safari_autofill
Closed

Try to enable submit button on safari autofill#3170
Crabcyborg wants to merge 3 commits into
masterfrom
try_to_enable_submit_button_on_safari_autofill

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

Pre-release
formidable-6.32.2b.zip

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced PayPal card field validation to properly detect when card inputs are completed. The submit button now enables at the appropriate time, improving support for both manual entry and autofilled card information.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

In paypal/js/frontend.js, the CardFields inputEvents configuration gains an onFocus no-op and an onBlur handler pointing to a new onCardFieldsBlur function. onCardFieldsBlur checks whether the active payment method is card and data.isFormValid is true, then sets cardFieldsValid = true and enables the submit button.

Changes

CardFields Autofill Blur Validation

Layer / File(s) Summary
onBlur wiring and onCardFieldsBlur implementation
paypal/js/frontend.js
inputEvents adds onFocus (no-op) and onBlur referencing a new onCardFieldsBlur function; onCardFieldsBlur sets cardFieldsValid to true and enables the submit button when the selected method is card and data.isFormValid is true.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop, hop, the blur event flies,
Autofill sneaks in, no one denies.
CardFields listens with a twitchy ear,
isFormValid true? The button's clear!
Submit enabled — the bunny cheers! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Try to enable submit button on safari autofill' clearly and specifically describes the main change: adding functionality to enable the submit button when Safari autofills card input fields. It directly relates to the PayPal CardFields blur handler implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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 try_to_enable_submit_button_on_safari_autofill

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 23, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in b096bc4...70edd5a 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 23, 2026 2:45p.m. Review ↗
JavaScript Jun 23, 2026 2:45p.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 +722 to +725
onFocus: function() {
// onBlur only triggers if onFocus is defined.
// But we don't need to do anything on focus.
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expected method shorthand


ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.45%. Comparing base (494b3dd) to head (60d00cd).
⚠️ Report is 126 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3170      +/-   ##
============================================
+ Coverage     26.43%   26.45%   +0.01%     
+ Complexity     9247     9236      -11     
============================================
  Files           149      149              
  Lines         31044    31004      -40     
============================================
- Hits           8206     8201       -5     
+ Misses        22838    22803      -35     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

Actionable comments posted: 1

🤖 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 `@paypal/js/frontend.js`:
- Around line 763-767: The onCardFieldsBlur function only handles the case when
data.isFormValid is true, leaving the cardFieldsValid state unchanged when the
form becomes invalid, which can result in a stale enabled submit button. Add an
else branch to the existing if condition that checks if selectedMethod is 'card'
and data.isFormValid is false, then set cardFieldsValid to false and call a
function to disable the submit button (similar to what onCardFieldsChange does
for the invalid case) to ensure the submit button state stays synchronized with
the actual form validity.
🪄 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: 23e7956b-0a7d-4480-bdac-3d1c3942c400

📥 Commits

Reviewing files that changed from the base of the PR and between b096bc4 and 70edd5a.

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

Comment thread paypal/js/frontend.js
Comment on lines +763 to +767
function onCardFieldsBlur( data ) {
if ( selectedMethod === 'card' && data.isFormValid ) {
cardFieldsValid = true;
enableSubmit();
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle invalid blur state to avoid stale enabled submit

On Line 764, the blur handler only updates state when data.isFormValid is true. If Safari autofill/event behavior skips onChange on an invalid transition, the submit button can stay enabled from a previous valid state. Mirror onCardFieldsChange by handling both branches in onCardFieldsBlur.

Proposed fix
 function onCardFieldsBlur( data ) {
-	if ( selectedMethod === 'card' && data.isFormValid ) {
-		cardFieldsValid = true;
-		enableSubmit();
-	}
+	if ( selectedMethod !== 'card' ) {
+		return;
+	}
+
+	cardFieldsValid = !! data.isFormValid;
+	if ( cardFieldsValid ) {
+		enableSubmit();
+	} else {
+		disableSubmit( thisForm );
+	}
 }
🤖 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 763 - 767, The onCardFieldsBlur function
only handles the case when data.isFormValid is true, leaving the cardFieldsValid
state unchanged when the form becomes invalid, which can result in a stale
enabled submit button. Add an else branch to the existing if condition that
checks if selectedMethod is 'card' and data.isFormValid is false, then set
cardFieldsValid to false and call a function to disable the submit button
(similar to what onCardFieldsChange does for the invalid case) to ensure the
submit button state stays synchronized with the actual form validity.

@Crabcyborg

Copy link
Copy Markdown
Contributor Author

Looks like onBlur never triggers either, so I'm just closing this for now.

@Crabcyborg Crabcyborg closed this Jun 23, 2026
@Crabcyborg Crabcyborg deleted the try_to_enable_submit_button_on_safari_autofill branch June 23, 2026 20:45
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