Repository navigation
Commit dfed2d9
authored
Fix shadowColor and outline prop defaults in BaseViewManagerDelegate
## Summary:
`BaseViewManagerDelegate` resets three props to values that don't match the `@ReactProp` defaults in `BaseViewManager` when they're removed:
| Prop | `BaseViewManager` default | `BaseViewManagerDelegate` |
| --- | --- | --- |
| `shadowColor` | `Color.BLACK` | `0` |
| `outlineOffset` | `0f` | `YogaConstants.UNDEFINED` |
| `outlineWidth` | `0f` | `YogaConstants.UNDEFINED` |
This affects every component whose view manager uses a codegen delegate (e.g. `Switch`, `Modal`, `RefreshControl`, and third-party Fabric components), but not `View`. Removing `shadowColor` from a view with `elevation` makes the shadow disappear instead of going back to black, and removing `outlineOffset` makes the outline disappear instead of drawing it with no offset.
This makes the delegate use the same defaults as `BaseViewManager`.
## Changelog:
[ANDROID] [FIXED] - Fix `shadowColor`, `outlineOffset` and `outlineWidth` not resetting to their defaults on components with a codegen view manager delegate
## Test Plan:
Added `setShadowColorResetsToBlack`, `setOutlineOffsetResetsToZero` and `setOutlineWidthResetsToZero` to `BaseViewManagerDelegateTest`. They pass with this change and fail without it (`0` instead of `-16777216`, `NaNf` instead of `0.0f`).
```
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests "com.facebook.react.uimanager.BaseViewManagerDelegateTest"
```
Also checked in RNTester on an OPPO K12x 5G (CPH2667, Android 16) with a `View` and a `Switch` side by side, each with `elevation` + `shadowColor: 'red'` and `outlineWidth` + `outlineOffset: 8`, then removing `shadowColor` and `outlineOffset`:
- Before: `View` resets correctly; on `Switch` the shadow and the outline both disappear.
- After: `Switch` matches `View` (black shadow, outline with no offset).
| Before | After |
| --- | --- |
| <img width="360" alt="Before" src="https://github.com/user-attachments/assets/94029d71-1786-45b1-bbcf-616aafcdd5ac" /> | <img width="360" alt="After" src="https://github.com/user-attachments/assets/014a6285-6dc4-44f4-94e7-cb9a9a54b285" /> |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Differential Revision: D127789219
Pull Request resolved: #594231 parent 3cee68f commit dfed2d9
2 files changed
Lines changed: 29 additions & 9 deletions
File tree
- packages/react-native/ReactAndroid/src
- main/java/com/facebook/react/uimanager
- test/java/com/facebook/react/uimanager
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| |||
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 125 | + | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
66 | 88 | | |
0 commit comments