Skip to content

Keep the mobile submit tap ahead of keyboard dismissal - #876

Open
amadad wants to merge 1 commit into
ymichael:mainfrom
amadad:fix/mobile-submit-keyboard-dismissal
Open

Keep the mobile submit tap ahead of keyboard dismissal#876
amadad wants to merge 1 commit into
ymichael:mainfrom
amadad:fix/mobile-submit-keyboard-dismissal

Conversation

@amadad

@amadad amadad commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevent the default focus transfer on the submit button's pointerdown so the prompt editor keeps focus through a tap. The click still owns the commit.

Why

On iOS, focus transfer happens before click. Moving focus from the editor to the submit button starts keyboard dismissal, which resizes the app shell while the tap is still resolving — so the submit races a viewport resize and can be lost. Keeping the editor focused for the duration of the tap removes the race; genuine focus changes elsewhere still dismiss the keyboard normally.

Scope

The handler is deliberately narrow — it only calls preventDefault() when all of the following hold:

  • the pointer is the primary button (event.button === 0)
  • the editor exists and is not destroyed
  • the editor is already focused

Keyboard activation is unaffected: Enter/Space on the button dispatch click without pointerdown, so they never reach this path.

Verification

  • apps/appPromptBoxInternal.test.tsx, 67/67 passing, including a new regression test asserting pointerdown is default-prevented, document.activeElement is still the editor, and onSubmit still fires once on the subsequent click
  • pnpm exec turbo run typecheck --filter=@bb/app clean

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.

1 participant