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.

Multiline TextInput Does Not Respect Line-Height

See original GitHub issue

Description

Related to #4977

TextInput with multiline={true} and line-height set on the value text should respect the line height value, but does not.

import React from 'react';
import {
  registerComponent,
} from 'react-native-playground';
import {
  StatusBar,
  StyleSheet,
  Text,
  View,
  TextInput,
} from 'react-native';

class App extends React.Component {
  render() {
    const loremText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque quis lacinia sapien, in bibendum est. "
    return (
      <View style={styles.container}>
        <Text style={styles.lorem}>
          {loremText}
        </Text>
    <TextInput style={[styles.lorem,styles.input]} multiline={true} value={loremText} />
        <StatusBar barStyle="default" />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#d3c012',
  },
  lorem: {
    textAlign: 'left',
    color: '#000',
    fontSize: 19,
    marginBottom: 5,
    lineHeight: 50,
  },
  input: {
   marginTop: 50,
   padding: 5,
   height: 150, 
   width: 300,
   borderColor: 'purple', 
   borderWidth: 2,
  }
});

This issue can be seen here: https://rnplay.org/apps/TYBoBw 2016-10-28_1356

Additional Information

  • React Native version: 0.36
  • Platform: both iOS, Android
  • Operating System: MacOS

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
SeanChenUcommented, Aug 8, 2017

For temp solution, I wrap <Text/> in <TextInput/>. Make sure the <TextInput/> doesn’t specify value props.

<TextInput
  onChangeText={(text) => {this.setState({content: text});}} 
  style={{lineHeight: 28}}>
  <Text>{this.state.text}</Text>
</TextInput>
7reactions
dmr07commented, Jul 12, 2017

Any updates on this? on 0.46.0 running on iOS. still having issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Am I misunderstanding React Native's TextInput multiline and ...
I assumed that using TextInput's multiline and numberOfLines properties like this would work, but alas when I reach row 5, the textBox just ......
Read more >
[TextInput] lineHeight in multiline TextInput - React Native
[TextInput] lineHeight in multiline TextInput. mkonicek. Moved from https://github.com/facebook/react-native/issues/1577.
Read more >
Can a single line text box be changed to a multiline ... - Quora
No, you cannot make a single-line text input behave like a multi-line textbox (i.e. allow line breaks support scrolling and resizing) with CSS....
Read more >
<Input /> | Widget API - Figma
Typing Enter blurs the input and triggers onTextEditEnd . On overflow, the text will wrap to the next line and the height of...
Read more >
Flexible, Multi-Line, Bulletproof Buttons - Litmus
Flexible, Multi-Line, Bulletproof Buttons ... The mso-flex-btn class does not seem to work in this example : ... [if gte mso 9]> /v:textbox...
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