Skip to content

Commit daa99f8

Browse files
fix(ios): preserve scroll position when nested sheet is dismissed (#468)
1 parent 685be60 commit daa99f8

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### 🐛 Bug fixes
1111

12+
- **iOS**: Fixed scroll position jumping when nested sheet is dismissed with inverted FlatList. ([#468](https://github.com/lodev09/react-native-true-sheet/pull/468) by [@lucasklaassen](https://github.com/lucasklaassen))
1213
- **Android**: Fixed present promise not resolving on resize. ([c3495500](https://github.com/lodev09/react-native-true-sheet/commit/c3495500) by [@lodev09](https://github.com/lodev09))
1314
- **iOS**: Fixed scroll view pinning to respect content view padding/margin. ([#429](https://github.com/lodev09/react-native-true-sheet/pull/429), [#446](https://github.com/lodev09/react-native-true-sheet/pull/446) by [@lodev09](https://github.com/lodev09))
1415
- **iOS**: Fixed footer not translating back when keyboard hides via ScrollView. ([#424](https://github.com/lodev09/react-native-true-sheet/pull/424) by [@lodev09](https://github.com/lodev09))

ios/TrueSheetContentView.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,15 @@ - (void)updateScrollViewHeight {
138138
CGFloat newHeight = containerView.bounds.size.height - scrollViewFrameInContainer.origin.y;
139139

140140
if (newHeight > 0) {
141+
// Preserve contentOffset before changing frame to prevent scroll jump
142+
CGPoint savedContentOffset = _pinnedScrollView.scrollView.contentOffset;
143+
141144
CGRect frame = _pinnedScrollView.frame;
142145
frame.size.height = newHeight;
143146
_pinnedScrollView.frame = frame;
147+
148+
// Restore contentOffset after frame change
149+
_pinnedScrollView.scrollView.contentOffset = savedContentOffset;
144150
}
145151
}
146152

0 commit comments

Comments
 (0)