facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.75k stars 24.16k forks source link

[ANDROID] TextAlign does not apply on Text components as children of TextInput #45275

Open TheProBro opened 1 month ago

TheProBro commented 1 month ago

Description

In android, applying textAlign for children on textInput does not apply. This works in iOS

Steps to reproduce

  1. Create a nested Text Component inside the TextInput
  2. Give Align Styles to the nested text component
  3. In android, the style does not apply, while does in ios

React Native Version

0.74.84

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
  Memory: 46.77 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: ~/.nvm/versions/node/v21.7.3/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v21.7.3/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11668458
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

N/A

Reproducer

https://snack.expo.dev/cQvwWTDFzX0THj9yNa8CA?platform=android

Screenshots and Videos

No response

meetdhanani17 commented 1 month ago

try to move object inside array it would be working ex. style={style.a} to style={[style.a]}

meetdhanani17 commented 1 month ago

https://snack.expo.dev/cQvwWTDFzX0THj9yNa8CA?platform=android

in this site it showing at end if i change textAlign center to right initial showing to center

TheProBro commented 1 month ago

@meetdhanani17 did you try on the android simulator? if yes can you share a screenshot as im not able to reproduce it on my end.

meetdhanani17 commented 1 month ago

@TheProBro

Screenshot 2024-07-10 at 11 29 14 AM

TheProBro commented 1 month ago

Yes this works, but the issue i raised was if i want to change text align of the text component, i cant as the textinput style overshadows, and this behaviour is not observed in iOS

meetdhanani17 commented 1 month ago

can you please share screenshot of both devices with issue difference

TheProBro commented 1 month ago
Screenshot 2024-07-10 at 12 06 33 PM Screenshot 2024-07-10 at 12 07 36 PM

The code is same but result is different