react / react/react-native

TextInput with controled selection clear children when change position

Open
#41,966 7 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: TextInput Issue: Author Provided Repro Needs: Triage :mag: Newer Patch Available
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

If you have TextInput with styled Text element inside (instead of value) and when you add controlled selection, the children are ignored and you have blank text even when you have initialValue.

Steps to reproduce
  1. Create TextInput with children
  2. Make it controlled selection Input
  3. Change the selection to move the cursor
  4. The children disappear
React Native Version

0.72.6

Affected Platforms

Runtime - Android

Output of npx react-native info
System:
  OS: Linux 6.6 Fedora Linux 39 (Xfce)
  CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Memory: 4.72 GB / 15.28 GB
  Shell:
    version: 5.2.21
    path: /bin/bash
Binaries:
  Node:
    version: 21.2.0
    path: ~/.nvm/versions/node/v21.2.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.2.3
    path: ~/.nvm/versions/node/v21.2.0/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/local/rvm/rubies/ruby-2.6.10/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Sorry, I have no idea why it can't find Android Studio and SDK on my system. I have them installed, and updated recently to 2023.1.1 from November 9, 2023.

Stacktrace or Logs
There are no stacktrace with this bug
Reproducer

https://github.com/jcubic/react-native-text-input.git

Screenshots and Videos

The First Input is with children (each line has it's on <Text>) the second is with value.

Peek 2023-12-17 17-56

The same happens when you move the cursor in the bottom Input, the top content disappears.

Peek 2023-12-18 21-32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked jcubic/react-native-text-input reproducer and reproduce the Android failure using controlled selection with styled children. Compare the children-based input with the value-based input while moving the cursor. Done means the styled children remain visible after selection changes, including with an initial value.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.