Skip to content

TextInput style, multiline, and caret bugs (new arch) #14357

Closed

Description

Problem Description

Hey folks! Wanted to report a couple TextInput bugs that I haven't been able to find a workaround for. These are issues I didn't see when looking through open issues for TextInput

  • If text extends past the end of the input, we can't access the text (it doesn't "scroll" to the overflowed text). It also increases the height of the input even though multiline is not set (and does not wrap)
  • Multiline calculates the number of lines incorrectly with varying characters, which becomes more noticeable when the text is long.
    • Properties like letterSpacing seem to be accounted for in determining number of lines, but doesn't show visually
    • ^^ Same for other font families - it seems to realize it's a different font family when trying to calculate number of lines/height, but visually it does not show the passed-in font
    • If a defaultValue (and I think value too) is set, that seems to be taken into account for multiline wrapping, but if it's removed it seems to treat it like that text still exists (2nd video)
  • Double clicking doesn't select text
  • The caret doesn't show for white inputs when Windows setting is on dark mode

I think all the multiline issues are a result of it rendering different styles than it's using to calculate the wrap. Calculating the wrap seems to successfully use the fonts that are passed in, but visually it's not showing those styles.

Attached is a video showing each of these

screen-capture.10.webm

This one is for the defaultValue bug

screen-capture.11.webm

This is on a fresh RNW new arch build using 0.78.0-preview.3 (but I think this issue predates that too).

Some other misc bugs - will update as I run into them:

  • Can paste rich text, including line breaks in a non-multiline input
  • Ctrl+A -> Ctrl+C -> Ctrl+V seems to copy the content with a line break and paste with line break, breaking input

Steps To Reproduce

  1. npx --yes @react-native-community/cli@next init TestApp --version "latest"
  2. cd TestApp
  3. yarn add react-native-windows@^0.78.0-preview.3
  4. yarn react-native init-windows --template cpp-app --overwrite
  5. npx react-native run-windows
  6. Add a to App.tsx
import React from 'react';
import {
  View,
  TextInput,
  Text,
} from 'react-native';

function App(): React.JSX.Element {
  return (
    <View>
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>Cursor missing when Windows Dark Mode + white input</Text></View>
        <TextInput
          style={{ width: 300, borderWidth: 1, borderColor: '#00ffff' }}
        />
      </View>
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>Cursor does successfully show when dark mode + black input</Text></View>
        <TextInput
          style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff' }}
        />
      </View>
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>If text extends past the end of the input, we can't access the text and cursor stays stuck to right. It also increases the height of the input for nothing (multiline is not set).</Text></View>
        <TextInput
          style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff' }}
        />
      </View>
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>When default value is set and removed, multiline still treats it like it's there.</Text></View>
        <TextInput
          style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff' }}
          defaultValue="Some default text that will eat up space."
        />
      </View
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>This has letterSpacing 10 - visually doesn't show, but seems to affect multiline height.</Text></View>
        <TextInput
          style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff', letterSpacing: 10 }}
          multiline={true}
        />
      </View>
    <View style={{ padding: 20 }}>
      <View style={{ marginBottom: 8 }}><Text>Other font families don't seem to visually show the difference. Eg. this should be Times New Roman.</Text></View>
      <TextInput
        style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff', fontFamily: 'Times New Roman' }}
          multiline={true}
        />
      </View>
      <View style={{ padding: 20 }}>
        <View style={{ marginBottom: 8 }}><Text>Double clicking doesn't select text.</Text></View>
        <TextInput
          style={{ width: 300, backgroundColor: '#000', color: '#fff', borderWidth: 1, borderColor: '#0000ff' }}
        />
      </View>
    </View>
  );
}

export default App;

Expected Results

No response

CLI version

npx @react-native-community/cli -v

Environment

npx @react-native-community/cli info

Community Modules

No response

Target Platform Version

None

Target Device(s)

No response

Visual Studio Version

None

Build Configuration

None

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

No response

Activity

  1. added
    Needs: Triage 🔍
    on Feb 19, 2025
  2. changed the title [-]TextInput style, multiline, and cursor bugs (new arch)[/-] [+]TextInput style, multiline, and caret bugs (new arch)[/+] on Feb 19, 2025
  3. austinhallock commented on Feb 23, 2025

    @austinhallock
    Author

    I have a workaround for this for now, in case anyone else runs into this. I'm wrapping the TextInput in a ScrollView, updating the width of the TextInput based on what's in it (hidden Text element with same font styles, and an onLayout), and scrolling the ScrollView from TextInput onSelectionChange

  4. added
    Area: Fabric
    New Architecture
    and removed
    Needs: Triage 🔍
    on Feb 24, 2025
  5. chrisglein commented on Feb 24, 2025

    @chrisglein
    Member

    Thanks for trying out the new architecture!

    Tatiana Kapos (@TatianaKapos) take a crack at a deeper dive on existing issues and as appropriate turn this into a set of discrete issues we can dig into.

  6. austinhallock commented on Feb 24, 2025

    @austinhallock
    Author

    I've mentioned it before, but the new architecture is incredible. Performance is so much better, and it's flexible enough that I've been able to solve most issues I run into (UWP was pretty limiting before).

    Keep up the great work :)

  7. raorugan commented on Jul 29, 2025

    @raorugan

    Hi Austin Hallock (@austinhallock) , how has been your experience using New architecture in React NAtive for windows from feature capabilities , perf, reliability etc. Any feedback you want to share with us with regards to new architecture?

  8. austinhallock commented on Jul 29, 2025

    @austinhallock
    Author

    Overall has been great! The Win32 Composition & WinAppSDK approach is much better (imo) than UWP.

    Perf is substantially better than it was on UWP. Reliability is a little worse still. Features generally are better since UWP itself was pretty limiting.

    Some recurring issues I've run into:

    • No way to trigger code on right click
    • Animations don't really work - I've gotten PanResponder working with some hacky approaches
    • Inputs are still a little janky compared to web inputs (lineHeight is respected but text isn't centered, no right click, etc...)
    • 3rd party component Portal LayoutMetrics / child LayoutMetrics aren't reliable
    • Performance seems to take a hit when images are rendered
    • ScrollViews don't seem to have a way to disable rubberbanding
    • FlatList doesn't seem to have inertia (scrolling feels janky).
    • App will crash if too much text is rendered
    • Small CSS bugs like negative marginRight not working with overflow: hidden

    Of these, the improvements that would make the biggest impact on our app would be:

    • Easy way to trigger code on Pressable right-click
    • Reliable native animations
    • More reliable Input
    • Inertia in FlatList scrolling
  9. austinhallock commented on Aug 4, 2025

    @austinhallock
    Author

    Forgot to mention the importance of having selectable text as well (#13112)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: FabricArea: TextInputNew Architecturebug

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions