Repository navigation
Commit 86695d8
Reset removed shadow, editable and persistentScrollbar props to their defaults (#59125)
Summary:
A prop removed from a component reaches the C++ props as `null`, and `convertRawProp` then returns its fallback argument. For these props the fallback differs from the field's declared default, so a component that had the prop and lost it is left with a value that a component which never had it does not have:
| Prop | Declared default | After removal |
| --- | --- | --- |
| `shadowRadius` | `3` | `0` |
| `shadowOffset` | `{width: 0, height: -3}` | `{width: 0, height: 0}` |
| `editable` (TextInput) | `true` | `false` |
| `persistentScrollbar` (ScrollView) | `false` | `true` |
| `sendMomentumEvents`, `nestedScrollEnabled` (Android ScrollView) | `false` | `true` |
On iOS, `RCTViewComponentView` applies the shadow values to the layer, so a view that sets `shadowRadius` or `shadowOffset` conditionally (a raised card, a pressed state) gets `layer.shadowRadius = 0` and `layer.shadowOffset = {0, 0}` once they are removed, instead of the defaults it started with. On Android, the props diff of `enablePropsUpdateReconciliationAndroid` reads the same values, so a `TextInput` that drops `editable={false}` stays read-only and a `ScrollView` that drops `persistentScrollbar` keeps it. `ScrollView` always passes `sendMomentumEvents` and `nestedScrollEnabled`, so those two only reach a direct user of the native component.
Each fallback is now the declared default, the value `setProp` (`enableCppPropsIteratorSetter`) already resets these props to.
## Changelog:
[GENERAL] [FIXED] - Reset a removed `shadowRadius`, `shadowOffset`, `editable` or `persistentScrollbar` prop to its default
Pull Request resolved: #59125
Test Plan:
- `ViewPropsTest` and `BaseTextInputPropsTest` parse a prop, then its removal, and compare the result with a default-constructed props object. On `main` they fail with `removed.shadowRadius` 0 against 3, `removed.shadowOffset.height` 0 against -3, and `removed.editable` false against true. `BaseTextInputProps` had no tests, so `textinput/tests/` is new: the SwiftPM target excludes it as the other targets exclude theirs, and the internal BUCK file now defines and links a `:tests` target. The view test target also declares the direct dependencies used by the new regression tests.
- A Fantom case in `ScrollView-itest.js` renders `persistentScrollbar={true}` and then no prop; on `main` the second render still carries `persistentScrollbar="true"`.
- I ran these in the `reactnativecommunity/react-native-android` image, linking the gtests against the Fantom runner's ReactCommon build: the new tests fail on `main` and pass with this change, and the whole Fantom suite passes with it. clang-format 21.1.2, Prettier, ESLint and Flow pass.
- RNTester release builds of `main` and of this change on an iPad (iOS 27.0.1): a view that loses `shadowRadius` and `shadowOffset` draws no shadow on `main` and the default one with this change ([before and after](#59125 (comment))).
- Internal validation after the BUCK updates: `buck2 test -j 16 fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/components/textinput:tests fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/components/view:tests -- --timeout=300` passed all 96 tests, including the new editable and shadow prop-removal regressions ([test run](https://www.internalfb.com/intern/testinfra/testrun/30680772508413679)). `arc f` and `arc lint -a` passed.
- Apple follow-up validation: reproduced both `testsApple` analysis failures with `buck2 build --flagfile fbsource//fbobjc/mode/buck2/ios-tests -c cxx.default_platform=iphonesimulator-arm64` before this update ([failure](https://www.internalfb.com/intern/sandcastle/instance/22518001181223006/)). The direct `core` dependencies caused Buck to import private core headers because the test target basename matches the core test registration. Removing those redundant dependencies avoids the basename `conversions.h` collisions while preserving access to the exported core headers through the component dependencies. Both Apple targets now build successfully ([build](https://www.internalfb.com/buck2/0e4dea76-a9d8-4bec-8fc9-9f74701bfd96)). Running the same two targets with `buck2 test` in the iOS-tests mode passes all 100 tests ([Apple test run](https://www.internalfb.com/intern/testinfra/testrun/11821949232723115)); the Linux targets on the updated base pass all 98 tests ([Linux test run](https://www.internalfb.com/intern/testinfra/testrun/3659175102648737)). `arc f` and focused `arc lint -a` on both BUCK files pass.
- Current cross-platform BUCK validation: the Android linker failure in `textinput:testsAndroid` reproduces locally using the exact CI command, `buck2 build --flagfile fbsource//fbandroid/mode/integration-tests-allowed-abi-x86` ([before](https://www.internalfb.com/buck2/f06f5508-6e4c-477e-ab58-9ec31f031e47)). A `test-deps` library now exports the core, view and attributed-string dependencies, matching the existing core test-dependency pattern. This links the symbols used by inline/default props constructors on Android without giving the Apple test direct access to conflicting private headers. The exact Android build now passes ([after](https://www.internalfb.com/buck2/856b54eb-3183-40e9-8237-60eae8a49158)). Both textinput and view test packages build for x86/x86_64 and armeabi-v7a/arm64-v8a, including the 32-bit target variants ([ARM build](https://www.internalfb.com/buck2/95780495-d6f6-47e8-98bc-f90275fc524a)). On the same Linux checkout, the iOS-tests-mode Buck run passes 100/100 tests ([Apple](https://www.internalfb.com/intern/testinfra/testrun/1688850268234094)) and the Linux run passes 98/98 tests ([Linux](https://www.internalfb.com/intern/testinfra/testrun/27303072800788143)). Android `buck2 test` successfully built the packages but reported `NO TESTS RAN`, so no Android runtime test pass is claimed. `arc f` and focused `arc lint -a` pass.
Reviewed By: christophpurrer
Differential Revision: D125706127
Pulled By: javache
fbshipit-source-id: c94b7a1d2e96cc59a958b34bc3242e2fc71d1fcd1 parent 1423ef0 commit 86695d8
8 files changed
Lines changed: 136 additions & 7 deletions
File tree
- packages/react-native
- Libraries/Components/ScrollView/__tests__
- ReactCommon/react/renderer/components
- scrollview
- platform/android/react/renderer/components/scrollview
- textinput
- tests
- view
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
44 | 72 | | |
45 | 73 | | |
46 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
| 566 | + | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments