Skip to content

[fc] Speculative fix for OTPElementUI stack overflow#13333

Open
mindy-stripe wants to merge 3 commits into
masterfrom
mindy/fc-stackoverflow
Open

[fc] Speculative fix for OTPElementUI stack overflow#13333
mindy-stripe wants to merge 3 commits into
masterfrom
mindy/fc-stackoverflow

Conversation

@mindy-stripe

@mindy-stripe mindy-stripe commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fix OTPElementUI stack overflow and first-digit paste display bug.

Previously, OTPElementUI advanced focus by calling FocusManager.moveFocus(FocusDirection.Next) in a loop after each character was entered. This triggered Compose's recursive focus traversal search, which combined with the Android autofill stack depth can cause a StackOverflowError on some devices. This is a speculative fix that should resolve the recursion when moving focus in the OTPElementUI.

https://jira.corp.stripe.com/browse/RUN_LINK_MOBILE-201

How has this been tested?

  • Automated
  • Manual

Reproducible test instructions

(note: couldn't repo the stack overflow myself, so the below is 🤖 speculation)

  1. Open the Financial Connections OTP screen and paste a 6-digit code — confirm all 6 boxes fill correctly, including the first
  2. Type digits one at a time — confirm focus advances to the next box after each entry
  3. Press backspace on an empty box — confirm focus retreats to the previous box and clears it
  4. Verify the StackOverflowError from the original report no longer occurs on a device with autofill enabled

@mindy-stripe mindy-stripe changed the title Mindy/fc stackoverflow [fc] Speculative fix for OTPElementUI stack overflow Jul 2, 2026
@mats-stripe mats-stripe requested a review from tillh-stripe July 6, 2026 17:58
@mindy-stripe mindy-stripe marked this pull request as ready for review July 6, 2026 19:52
@mindy-stripe mindy-stripe requested review from a team as code owners July 6, 2026 19:52
),
keyboardActions = KeyboardActions(
onNext = { focusManager.moveFocusSafely(FocusDirection.Next) },
onDone = { focusManager.clearFocus(true) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No more focus clearing when done?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm, it still does dismiss the keyboard in the FC flow. Also works in the other places where it's used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my main concern with this approach is with RTL languages, does using index + 1 / index - 1 cause problems there?

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.

2 participants