Commit 52aee50
underlineColor transparent not working on API 21 (#30897)
Summary:
This issue fixes facebook/react-native#29379 `underlineColorAndroid'='transparent'` does not work on Android API 21.
Setting `style: { bottomBorderColor: 'transparent'}` fixes the issue.
The following steps fix underlineColorAndroid on Android API 21:
- Store the bottomBorderColor in a local variable
- Then set the bottomBorderColor to the same color of underlineColorAndroid
- Set underlineColorAndroid
- Then Set the bottomBorderColor to the previous color previously stored in the local variable
This change requires `ReactViewBackgroundDrawable` method `getBorderColor` to be public and accessible from `ReactTextInputManager` to retrieve the border color.
https://github.com/facebook/react-native/blob/6061b7928320c64a94716ce3d6646667ebf3f6b5/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java#L1231-L1236
Related Discussions facebook/react-native#18938 facebook/react-native#18988 facebook/react-native#29412 (comment)
More Information at #4 (comment)
## Changelog
[Android] [Fixed] - Fix underlineColorAndroid transparent not working on API 21
Pull Request resolved: facebook/react-native#30897
Test Plan:
This changes fix the Java API which can not be tested as explained in commit facebook/react-native@709a441
The java TextInputTest was excluded from the test suite in commit facebook/react-native@709a441 as they need the Yoga libraries to run
**<details><summary>CLICK TO OPEN TESTS RESULTS - API 21</summary>**
<p>
Does not show underline by default (`transparent`)
```javascript
<TextInput />
```
<image src="https://user-images.githubusercontent.com/24992535/107060953-dee34d00-67d7-11eb-8f01-360dbb1420b8.png" width="150" />
```javascript
<TextInput underlineColorAndroid="red" />
```
<image src="https://user-images.githubusercontent.com/24992535/107061134-194cea00-67d8-11eb-9da1-9780b1aa8294.png" width="150" />
```javascript
<TextInput
underlineColorAndroid="green"
style={
{
borderBottomColor: 'red',
borderBottomWidth: 2,
borderTopColor: 'black',
borderTopWidth: 4
}
}
/>
```
<image src="https://user-images.githubusercontent.com/24992535/107062411-9167df80-67d9-11eb-810c-749992d8d2d3.png" width="150" />
```javascript
<TextInput
style={
{
borderBottomColor: 'red',
borderBottomWidth: 2,
borderTopColor: 'black',
borderTopWidth: 4
}
}
/>
```
<image src="https://user-images.githubusercontent.com/24992535/107062735-e6a3f100-67d9-11eb-93c3-02cd768f8421.png" width="150" />
```javascript
<TextInput
underlineColorAndroid="blue"
style={
{
borderBottomColor: 'red',
borderBottomWidth: 2,
borderTopColor: 'black',
borderTopWidth: 4,
borderLeftColor: 'pink',
borderLeftWidth: 7,
borderRightColor: 'yellow',
borderRightWidth: 7,
}
}
/>
```
<image src="https://user-images.githubusercontent.com/24992535/107063263-75b10900-67da-11eb-97ab-316736d525a2.png" width="150" />
```javascript
<TextInput
underlineColorAndroid="transparent"
style={
{
borderBottomColor: 'red',
borderBottomWidth: 2,
borderTopColor: 'black',
borderTopWidth: 4,
borderLeftColor: 'pink',
borderLeftWidth: 7,
borderRightColor: 'yellow',
borderRightWidth: 7,
}
}
/>
```
<image src="https://user-images.githubusercontent.com/24992535/107063332-8792ac00-67da-11eb-82fc-99793bf4d49d.png" width="150" />
</p>
</details>
Reviewed By: cortinico
Differential Revision: D33906415
Pulled By: lunaleaps
fbshipit-source-id: bd7efe4aac40ad701aec83f051ac40dcd4a99cda1 parent 1804951 commit 52aee50
File tree
4 files changed
+19
-2
lines changed- ReactAndroid/src/main/java/com/facebook/react/views
- textinput
- view
4 files changed
+19
-2
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
917 | 921 | | |
918 | 922 | | |
919 | 923 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
640 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
641 | 650 | | |
642 | 651 | | |
643 | 652 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1259 | 1259 | | |
1260 | 1260 | | |
1261 | 1261 | | |
1262 | | - | |
| 1262 | + | |
1263 | 1263 | | |
1264 | 1264 | | |
1265 | 1265 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
0 commit comments