react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[IOS 15] TextInput textAlign:right space issue

Open Chant-Lee opened this issue 2 years ago • 19 comments

Description

If use TextInput component with textAlign:'right' property, when typing space, it is not shown until entering another character (not space)

Steps to Reproduce

      <TextInput style={{ textAlign: 'right' }} placeholder={'Please input '} />

Expected Results Show space in TextInput

Version

0.57.7

Output of react-native info

React Native Environment Info: System: OS: macOS 11.6.1 CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz Memory: 63.70 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.11.0 - ~/.nvm/versions/node/v15.11.0/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.6.0 - ~/.nvm/versions/node/v15.11.0/bin/npm Watchman: 2021.06.07.00 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5977832 Xcode: 12.2/12B45b - /usr/bin/xcodebuild npmPackages: react: 16.6.1 => 16.6.1 react-native: 0.57.7 => 0.57.7

Steps to reproduce

  <TextInput style={{ textAlign: 'right' }} placeholder={'Please input '} />

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

No response

Chant-Lee avatar Dec 09 '21 09:12 Chant-Lee

I tried the following methods and they didn't work

   <TextInput
        value={value && value.replace(/\u0020/g, '\u00a0')} 
        onChangeText={text => {
          const actualText = text.replace(/\u00a0/g, '\u0020')
          setValue(actualText)
        }}
        style={{ textAlign: 'right' }}
        placeholder={'Please Input'}
      />

Chant-Lee avatar Dec 09 '21 09:12 Chant-Lee

Same issues,anyone here?

supervons avatar Dec 09 '21 12:12 supervons

Same issues

tracyhyq avatar Dec 09 '21 13:12 tracyhyq

facing the same issue, any bro can help me :(

yangzhen0 avatar Dec 09 '21 13:12 yangzhen0

same issues😭😭

MrYz912 avatar Dec 09 '21 13:12 MrYz912

I add multiline={true} props, can typing space but keyboard return will add a newline.

        <TextInput
          value={value && value.replace(/\u0020/g, "\u00a0")}
          onChangeText={text => {
            const actualText = text.replace(/\u00a0/g, "\u0020");
            setValue(actualText);
          }}
          multiline={true} // Add this.
          style={{ textAlign: "right" }}
          placeholder={"Please Input"}
        />

supervons avatar Dec 10 '21 01:12 supervons

I have the same issue, too 😭

Darkindom avatar Dec 10 '21 02:12 Darkindom

same issues. sb can help?

Jaycexx avatar Dec 10 '21 02:12 Jaycexx

I would be fired if this issue is not resolved, pls help me !!!!

VladimirZL avatar Dec 10 '21 03:12 VladimirZL

I tried,the user experience is not good

Chant-Lee avatar Dec 13 '21 02:12 Chant-Lee

Seems to be an issue in iOS's UITextField itself: https://stackoverflow.com/questions/19569688/right-aligned-uitextfield-spacebar-does-not-advance-cursor-in-ios-7

RickardZrinski avatar Jan 02 '22 10:01 RickardZrinski

Facing same issue.

I would be fired if this issue is not resolved, pls help me !!!!

Just curious to know, did they fired you yet?

arpitBhalla avatar May 11 '22 15:05 arpitBhalla

I have the same problem....

riledv avatar Aug 26 '22 21:08 riledv

duplicate: https://github.com/facebook/react-native/issues/10218

efstathiosntonas avatar Sep 12 '22 14:09 efstathiosntonas

Any update on this?

dilan-dio4 avatar Oct 04 '22 17:10 dilan-dio4

I was able to have a fix using styling. I have a container and text input inside. Put the textAlign of the input to 'left' and container flex-direction to 'row-reverse'. Works on iOs 16.

container: {
  flex: 1,
  flexDirection: 'row-reverse',
},
textInput: {
  textAlign: 'left',
},

https://user-images.githubusercontent.com/111883595/228593077-1c4b90ff-5fa6-4c0c-b71b-3a9d32222086.mov

dtalbot-goto avatar Mar 29 '23 15:03 dtalbot-goto

I was able to have a fix using styling. I have a container and text input inside. Put the textAlign of the input to 'left' and container flex-direction to 'row-reverse'. Works on iOs 16.

container: {
  flex: 1,
  flexDirection: 'row-reverse',
},
textInput: {
  textAlign: 'left',
},

Screen.Recording.2023-03-29.at.11.40.49.AM.mov

unfortunately it does not work well with a placeholder in the textinput (cursor is first displayed on the left)

mlecoq avatar Nov 09 '23 19:11 mlecoq

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 08 '24 05:05 github-actions[bot]

This issue is still present

mlecoq avatar May 08 '24 07:05 mlecoq