Skip to content

Implement keep-focus-on-submit on Android and report focus state for press dispatch - #53

Open
gwleuverink wants to merge 2 commits into
NativePHP:mainfrom
trailhead-labs:fix/335-keep-focus-on-submit
Open

Implement keep-focus-on-submit on Android and report focus state for press dispatch#53
gwleuverink wants to merge 2 commits into
NativePHP:mainfrom
trailhead-labs:fix/335-keep-focus-on-submit

Conversation

@gwleuverink

@gwleuverink gwleuverink commented Aug 17, 2026

Copy link
Copy Markdown

Companion to NativePHP/mobile-air#353, the input-renderer half of the keyboard-dismissal fix for NativePHP/mobile-air#335. The full story and behaviour matrix live there.

The reproduced problem was a chat composer losing the keyboard on every button send. The direction is symmetry: both platforms drop the keyboard on submit and on taps outside the field, keep-focus-on-submit is the one opt-out, and it has to actually work everywhere. iOS defaults were already right. Android's were not, and the attribute did nothing there.

On Android, the renderers never parsed keep_focus_on_submit, and supplying KeyboardActions had silently replaced Compose's default hide-on-Done, which is why Android kept the keyboard on submit while the docs said otherwise. The prop is now parsed, and submit clears focus by default and keeps it with the attribute, in all three input variants.

On both platforms the inputs now report their focus state and keep-focus flag to mobile-air's KeyboardFocusPolicy, which press dispatch consults to decide whether a button tap dismisses. The iOS input also registers a flush hook so a press can push the field's latest text, including a tap-committed autocorrection, to PHP before the press event lands.

This PR carries the Android behavioural change: submit and button taps start dropping the keyboard by default. Existing code keeps running, chat-style screens add keep-focus-on-submit to keep the old feel.

It also references KeyboardFocusPolicy, which ships in the mobile-air companion, so the composer constraint on nativephp/mobile needs to require the release that includes it. Left untouched pending the release plan.

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