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.

tvOS: TextInput backgroundColor style prop has inconsistent UI when highlighted.

See original GitHub issue
Screenshot 2019-10-18 at 2 59 37 PM

React Native version: react-native-tvos@0.60.4-6

Code

<TextInput style={styles.textInput} placeholder="Email Address" />
const styles = StyleSheet.create({
    textInput: {
        backgroundColor: '#D5D5D5',
        height: 72,
        textAlign: 'center',
        fontSize: 32,
        fontWeight: '300',
        marginBottom: 28,
  },
})

Describe what you expected to happen:

TextInput has default tvOS UI experience that I need to customize. Providing styling to TextInput should disable that default tvOS UI experience.

Snack, code example, screenshot, or link to a repository:

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
danychicommented, Aug 3, 2022

I have been working on demos for an upcoming medium article on React Native TV user input. As part of this work, I found that there are issues on Android TV with having TextInput get the focus from a Touchable when navigating with the DPad.

The technique below seems to solve that issue, and wrapping the TextInput in a Touchable seems to restore the styling that you would expect.

const App = () => {
  const [inputText, setInputText] = useState('');
  const textInputRef = useRef();
  return (
    <SafeAreaView style={styles.container}>
      <ScrollView
        style={[styles.container, {backgroundColor: colors.background}]}>
            <TouchableOpacity
              style={{flex: 1}}
              onPress={() => textInputRef?.current?.focus()}>
              <TextInput
                ref={textInputRef}
                label="Text Input"
                value={inputText}
                onChangeText={(src) => setInputText(src)}
              />
            </TouchableOpacity>
      </ScrollView>
    </SafeAreaView>
  );
};

This workaround seems to partially work, but when the TouchableOpacity uses a light background like “white” and the Text uses a “black” color, then the text is not visible as can be seen in this screenshot:

Black background - White text

Screenshot 2022-08-03 at 16 04 46

White background - Black text

Screenshot 2022-08-03 at 16 05 27

1reaction
douglowdercommented, Oct 18, 2019

This seems to be a long-standing issue with RN, where styles supported in <Text/> are not necessarily supported in <TextInput/>. https://github.com/facebook/react-native/issues/7070

Read more comments on GitHub >

github_iconTop Results From Across the Web

tvOS: TextInput backgroundColor style prop has inconsistent ...
The technique below seems to solve that issue, and wrapping the TextInput in a Touchable seems to restore the styling that you would...
Read more >
React Native TextInput background color looks double layered ...
ios - React Native TextInput background color looks double layered when it's set to color with transparence - Stack Overflow. Stack Overflow ...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Added emulation toggles for prefers-reduced-motion and prefers-contrast CSS media features (257197@main); Fixed corrupted styles when adding a new property ...
Read more >
Fullstack react native sample code - Weebly
During runtime React Native takes care of rendering the actual native UI for each ... We only have a single prop attached, style,...
Read more >
TextInput - React Native
TextInput has by default a border at the bottom of its view. This border has its padding set by the background image provided...
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