Skip to content

[Masterclass] No way to keep the keyboard up when sending via a button - tap-to-dismiss fires on every tap outside the input #335

Description

@shrutibalasawebdev

What were you trying to do?

Building a chat composer - a <bare-text-input> and a send <pressable> in the same <row> - where sending a message keeps the field focused and the keyboard up, so the user can type the next message immediately.

What happened?

Expected: some way to keep the field focused through a programmatic send.

Any of:

  • an opt-out for tap-to-dismiss (per-screen or per-element), or
  • an exemption for <pressable> taps, or
  • a focus API - something that takes a native:key and focuses that element.

Actual: while the input is focused, tapping anywhere outside it dismisses the keyboard, including the send button in the same row. The gesture is screen-wide, not specific to interactive elements - tapping a plain <column> with no @press dismisses it too.

keep-focus-on-submit solves this only for the return key, because return is handled inside the field and never triggers the dismiss gesture. Every other send path loses focus.

How to reproduce the bug

<column class="w-full h-full bg-theme-background">
    <row class="w-full px-3 pt-3 pb-8 gap-2 items-center bg-theme-surface">
        <bare-text-input
            native:key="message-input"
            native:model="draft"
            placeholder="Type your message..."
            class="flex-1 bg-theme-surface-variant rounded-full px-4 py-3 text-theme-on-surface" />
        <pressable @press="send" class="bg-theme-primary rounded-2xl w-[48] h-[48] items-center justify-center">
            <icon name="paperplane.fill" :size="20" class="text-theme-on-primary" />
        </pressable>
    </row>
</column>
  1. Tap the input and type - the keyboard comes up.
  2. Tap the send button. The keyboard dismisses.

Debug Output

   INFO  NativePHP Mobile.  

+--------------------+----------+
| Package Version    | dev-main |
| PHP Version (Host) | 8.4.18   |
| OS                 | Darwin   |
| OS Version         | 25.5.0   |
| Embedded PHP       | 8.4.24   |
+--------------------+----------+

   INFO  Installed Plugins.  

+---------------------------------+----------+
| Package                         | Version  |
+---------------------------------+----------+
| nativephp/mobile-secure-storage | 1.0.2    |
| nativephp/mobile-ui             | dev-main |
+---------------------------------+----------+

   INFO  Development Tools.  

+----------------+--------------------------------------+
| Xcode          | Xcode 26.5                           |
| Android Studio | Android Studio AndroidStudio2025.2.3 |
| Gradle         | Gradle 8.14.5                        |
| Java           | openjdk version "17.0.18" 2026-01-20 |
| CocoaPods      | CocoaPods 1.16.2                     |
+----------------+--------------------------------------+

Which operating systems have you seen this occur on?

macOS

Which platforms were you trying to build for?

iOS (Device)

Notes

Sending a message is the most repeated interaction in a chat app, so losing the keyboard on every send means re-tapping the field each time.

The other way to send is by pressing return, with keep-focus-on-submit - but that only works on a single-line input. In a multi-line composer, return needs to insert a line break, so it can't also be the send key. Right now you have to pick one: line breaks, or a keyboard that stays up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions