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

TextInput color does not obey alpha when using white

Open jagorrin opened this issue 6 years ago • 3 comments

Environment

If you are using latest version:

  1. react-native -v: 0.60.6
  2. react-native run-windows --info: System: OS: Windows 10 10.0.18363 CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz Memory: 18.01 GB / 31.84 GB Binaries: Node: 10.15.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.21.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.6 => 0.60.6 react-native-windows: 0.60.0-vnext.133 => 0.60.0-vnext.133 rnpm-plugin-windows: 0.3.5 => 0.3.5 Installed UWP SDKs: 10.0.14393.0 10.0.15063.0 10.0.16299.0 10.0.17134.0 10.0.17749.0 10.0.17763.0 10.0.18362.0

Then, specify:

  • Target Platform Version(s): 10.0.18362.0
  • Target Device(s): Desktop
  • Visual Studio Version: 2017
  • Build Configuration: Debug

Steps to Reproduce

Create a project using react-native-windows that includes a TextInput. Provide a "color" prop of rgba(255,255,255,0.5).

Expected Behavior

The TextInput should have a text color of roughly gray on a black background.

Actual Behavior

The TextInput has a text color of white at full opacity. Interestingly, if you try the same thing but with the color red, rgba(255,0,0,0.5), the red is in fact semi-transparent. So it looks like RNW does support the alpha property of the color and obey it, but not for white. Also, of note, the placeholder is being provided the same color and is obeying the alpha and is gray in color over a black background.

Screenshots

Example on Electron: electron_searchterm

The same color, but using RNW: new_searchterm

Red example:

Full opacity: red_full

Half opacity: red_half

By this example, I can see that the rgba format is supported and that the platform obeys the alpha. However, when using white, it does not.

jagorrin avatar Feb 13 '20 00:02 jagorrin

@jagorrin Can you share your code? I tried the code below and it seems to be working fine.

  textInputStyle: {
    color: 'rgba(255,255,255,0.5)',
    backgroundColor: 'black',
    fontSize: 20,
    height: 50
   }

image

kaiguo avatar Feb 25 '20 02:02 kaiguo

I use the default background color of black rather than manually specifying it. I specify a font family, but I tried removing it and that did not fix the issue. I am also using a borderRadius, and removing that also did not fix the issue.

textInputStyle: {
    borderRadius: 16,
    color: 'rgba(255,255,255,0.5)',
    fontFamily: "Segoe UI",
    fontSize: 14,
    height: 32,
}

I then removed the styling and replaced it with yours above, and that did not fix the issue either. Here is a screenshot using the styles in your previous message:

example

jagorrin avatar Feb 25 '20 19:02 jagorrin

@jagorrin turns out this is a bug in TextBox itself and it should be fixed on xaml side, I created a bug to track, https://microsoft.visualstudio.com/OS/_workitems/edit/25376371.

Before that gets fixed, the work-around will be changing the color to any non-default value ((255,255,255) is the default TextBox foreground color in dark mode). rgba(255, 255, 254, 0.5) should work.

kaiguo avatar Feb 28 '20 00:02 kaiguo