Skip to content

TextInput with blurOnSubmit={false} never gets events for Enter key (onSubmitEditing, onEndEditing, or even onKeyPress). #1082

Open
@jmbldwn

Description

@jmbldwn

Environment

react-native -v:
6.14.15

npm ls react-native-macos:
serial@0.0.1 /Users/jim/development/mac/serial
└── react-native-macos@0.64.29 

node -v:
v14.18.1

npm -v:
6.14.15

yarn --version:
1.22.17

xcodebuild -version:
Xcode 13.2.1
Build version 13C100

Steps to reproduce the bug

I have a single TextInput in my app, and I never want it to lose focus, so I set blurOnSubmit={false}.
I want to get events when the Enter/Return keys are hit.

            <TextInput
                ref={inputRef}
                style={styles.input}
                autoFocus={true}
                onChangeText={setText}
                onSubmitEditing={onSubmitEditing}
                value={text}
                blurOnSubmit={false}
            />

WIth this configuration, I don't get onSubmitEditing events. If I turn off blurOnSubmit, I get them.

Feels like a bug, but maybe I'm missing how to do this correctly.

Expected Behavior

TextInput keeps focus, and emits an event when enter key is hit.

Actual Behavior

No events from enter key.

Reproducible Demo

Here's a snack that works in expo. This fails on macOS.

https://snack-web-player.s3.us-west-1.amazonaws.com/v2/43/index.html?initialUrl=exp%3A%2F%2Fexp.host%2F%40snack%2FppYQvRyBl%2Bwx!xOlCs9O&origin=https%3A%2F%2Fsnack.expo.dev&verbose=false

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions