Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Focus Loop in PaymentElement Causes Input Fields to Lose Focus Repeatedly. #2021

Open
x544D opened this issue Dec 23, 2024 · 0 comments · May be fixed by #2022
Open

[Web] Focus Loop in PaymentElement Causes Input Fields to Lose Focus Repeatedly. #2021

x544D opened this issue Dec 23, 2024 · 0 comments · May be fixed by #2022
Labels
needs triage Needs triage

Comments

@x544D
Copy link

x544D commented Dec 23, 2024

Describe the bug

When using the PaymentElement widget from the flutter_stripe_web package, input fields lose focus instantly after being selected. This issue is observed primarily in Chrome browsers, where the Focus state toggles repeatedly, making the input fields unusable.


To Reproduce

Steps to reproduce the behavior:

  1. Initialize the PaymentElement widget with the following parameters:
    PaymentElement(
      onCardChanged: (details) {},
      clientSecret: secret, // secret is always there.
      width: MediaQuery.of(context).size.width,
      enablePostalCode: false,
      appearance: const ElementAppearance(
        theme: ElementTheme.night,
      ),
    ),
  2. Run flutter run -d chrome
  3. Attempt to focus on any input field (e.g., credit card number).
  4. Observe that the input loses focus immediately after gaining focus.
Screen.Recording.2024-12-23.at.23.26.29.mov

Expected behavior

Input fields in the PaymentElement widget should retain focus when selected, allowing users to enter their details seamlessly.


Smartphone / tablet

  • Device: N/A (Web platform)
  • Browser: Chrome Version 131.0.6778.140
  • OS: macOS 14.4
  • Package version: flutter_stripe_web: ^6.3.0 | flutter_stripe: ^11.3.0
  • Flutter version: 3.24.4

Additional context

  • This issue does not occur on Safari, where the widget works as expected.
  • The following code logs indicate continuous focus toggling:
    upon tweaking onFocusChange to print focus as follow :
image
Focus Gained  
Focus Lost  

and upon uncommenting the commented :

/*  if (focus)
          element?.focus();
        else
          element?.blur(); */

the loop happens.

  • Potential Cause: Interaction between Flutter’s FocusNode and the underlying iframe behavior of the Stripe Payment Element.
@x544D x544D added the needs triage Needs triage label Dec 23, 2024
@x544D x544D changed the title Focus Loop in PaymentElement Causes Input Fields to Lose Focus Repeatedly. [Web] Focus Loop in PaymentElement Causes Input Fields to Lose Focus Repeatedly. Dec 23, 2024
@x544D x544D linked a pull request Dec 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant