Commit 216606a
committed
Fix maintainVisibleContentPosition ignoring contentInset in Fabric ScrollView
The Fabric implementation of `_adjustForMaintainVisibleContentPosition` did
not account for `contentInset` when computing the autoscroll threshold
comparison or the scroll target position, unlike the Paper implementation
(`RCTScrollView.m`) which already handles this correctly.
When a non-zero `contentInset` is set on a scroll view, two bugs occurred:
1. The threshold comparison used raw `contentOffset` instead of the
inset-adjusted value, causing autoscroll to fire incorrectly.
2. The autoscroll target was hardcoded to `0` instead of `-inset`, causing
the scroll view to jump to the wrong position.
Fix: compute `bottomInset`/`leftInset` (respecting `isInverted`) and use
them to adjust both the threshold comparison and the `scrollToOffset` target,
matching the existing Paper logic in `RCTScrollView.m`.
No behavior change when `contentInset` is zero.1 parent 52d87f9 commit 216606a
1 file changed
Lines changed: 6 additions & 4 deletions
File tree
- packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
1099 | | - | |
| 1099 | + | |
| 1100 | + | |
1100 | 1101 | | |
1101 | 1102 | | |
1102 | 1103 | | |
1103 | 1104 | | |
1104 | 1105 | | |
1105 | | - | |
| 1106 | + | |
1106 | 1107 | | |
1107 | 1108 | | |
1108 | 1109 | | |
1109 | 1110 | | |
1110 | 1111 | | |
1111 | 1112 | | |
1112 | 1113 | | |
1113 | | - | |
| 1114 | + | |
| 1115 | + | |
1114 | 1116 | | |
1115 | 1117 | | |
1116 | 1118 | | |
1117 | 1119 | | |
1118 | 1120 | | |
1119 | | - | |
| 1121 | + | |
1120 | 1122 | | |
1121 | 1123 | | |
1122 | 1124 | | |
| |||
0 commit comments