question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android TV: Keyboard automatically open when pressing numeric key in specific conditions

See original GitHub issue

Description

Keyboard automatically open when pressing numeric key (KEYCODE_1, … ) after removing an InputText from the View on AndroidTV (not tested on ios, but not sure it makes sens as there is no key number on apple TV)

React Native version:

0.66.3-3

Steps To Reproduce

Run following sample. This is just a dummy InputText which is removed from main View onSubmit. Once you end typing text, the view disappear. At that point, if you press numerical key on remote control, the keyboard is automatically opened.

As a complementary test, if you initialize show state to false and input numerical Keycode, the issue is not reproduced.

Reproduced on multiple Androidtv devices and on emulator. Keycode can be simulate with following adb command: ‘adb shell input keyevent KEYCODE_1’

Expected Results

The keyboard should not show at that point.

code example:

Sample project : https://github.com/freeboub/React-Native-tvos-demo/tree/sample_keyboard_issue

code sample code:

` import React, {useRef} from ‘react’; import {View, TextInput, LogBox} from ‘react-native’;

const TVEventHandlerView = () => { const [show, setShow] = React.useState(true);

const firstRef = useRef();

return ( <> {show && ( <> <TextInput ref={firstRef} defaultValue={‘hello’} showSoftInputOnFocus={true} autoFocus={true} editable={true} onChangeText={() => { console.log(‘onTextChange’); }} onSubmitEditing={() => { console.log(‘onSubmitEditing’); setShow(false); }} placeholder={‘Search…’} /> </> )} </> ); };

export default function App() { return ( <View style={{flex: 1}}> <TVEventHandlerView /> </View> ); } ` Additionnal interesting informations:

  • If I add a TouchableWithoutFeedback after the InputText the issue is not reproduce (I think focus correctly moves to the TouchableWithoutFeedback)
  • If I launch google voice assistant the incorrect behavior disappear.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
douglowdercommented, Apr 8, 2022

Thanks for the detailed information and repro, and for creating the new issue for the core repo. I’ll see what the RN core Android developers think about what the issue really is, before picking this up.

0reactions
freeboubcommented, Apr 8, 2022

Here are some addtionnal informations:

  • to workaround the issue I tried to implement by own InputText component (I can share it if needed), but the same issue is reproduced with a custom component, so I think we can asume the issue is not directly linked to EditText management in react-native. It’s really looks like a low level issue. Maybe a reference leak …
  • I found an ‘ugly’ workaround which is working. When a TextInput is blured or unmounted, I launch an empty transparent activty. This activity just call finish onResume… Then the activity stack is correctly cleared and keyboard doesn’t take the focus instead of our app. I causes a very small freeze in UI, but It is better than this issue.
Read more comments on GitHub >

github_iconTop Results From Across the Web

The Virtual keyboard does not appear on the screen, even ...
The Virtual keyboard does not appear on the screen, even when a text input box is selected.
Read more >
show soft keyboard automatically when focus is on an EditText
For anyone wondering, this method does not open the soft keyboard when a hardware keyboard is attached. I just tested with a USB...
Read more >
The on-screen keyboard doesn't appear when I press ... - Sony
The on-screen keyboard doesn't appear when I press the Enter button on my TV remote · On the supplied remote control, press the...
Read more >
CN51 Android How to prevent virtual keyboard from popping up
Go to 'Apps' > 'Settings > Personal' > 'Language & Input' > 'Keyboard & Input Methods' · Tap on the 'Current keyboard' option....
Read more >
Keyboard devices - Android Open Source Project
Keyboard behavior is determined by the keyboard's key layout, key character map and input device configuration. Refer to the following sections ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found