Skip to content

Commit 54bcbd7

Browse files
authored
fix(ios): footer keyboard handling with scrollview dismiss (#424)
* fix(ios): footer keyboard handling with scrollview dismiss * docs: update changelog for #424
1 parent 1bb9a09 commit 54bcbd7

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

CHANGELOG.md

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

55
### 🐛 Bug fixes
66

7+
- **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))
78
- **iOS**: Fixed `backgroundBlur` and `backgroundColor` not working together. ([#423](https://github.com/lodev09/react-native-true-sheet/pull/423) by [@lodev09](https://github.com/lodev09))
89
- **iOS**: Fixed `present()` called from `useEffect` not working due to mount event not firing. ([#421](https://github.com/lodev09/react-native-true-sheet/pull/421) by [@lodev09](https://github.com/lodev09))
910
- Fixed sheet content becoming empty after rapidly presenting/dismissing. ([#419](https://github.com/lodev09/react-native-true-sheet/pull/419) by [@lodev09](https://github.com/lodev09))

ios/TrueSheetView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,13 @@ - (void)viewControllerDidDrag:(UIGestureRecognizerState)state
549549
}
550550

551551
- (void)viewControllerWillDismiss {
552-
[_containerView cleanupKeyboardHandler];
553552
if (!_dismissedByNavigation) {
554553
[TrueSheetLifecycleEvents emitWillDismiss:_eventEmitter];
555554
}
556555
}
557556

558557
- (void)viewControllerDidDismiss {
558+
[_containerView cleanupKeyboardHandler];
559559
if (!_dismissedByNavigation) {
560560
_dismissedByNavigation = NO;
561561
_pendingNavigationRepresent = NO;

ios/TrueSheetViewController.mm

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,14 @@ - (BOOL)isDismissing {
245245
- (void)emitWillDismissEvents {
246246
if (self.isDismissing && !_isWillDismissEmitted) {
247247
_isWillDismissEmitted = YES;
248-
dispatch_async(dispatch_get_main_queue(), ^{
249-
if ([self.delegate respondsToSelector:@selector(viewControllerWillBlur)]) {
250-
[self.delegate viewControllerWillBlur];
251-
}
252248

253-
if ([self.delegate respondsToSelector:@selector(viewControllerWillDismiss)]) {
254-
[self.delegate viewControllerWillDismiss];
255-
}
256-
});
249+
if ([self.delegate respondsToSelector:@selector(viewControllerWillBlur)]) {
250+
[self.delegate viewControllerWillBlur];
251+
}
252+
253+
if ([self.delegate respondsToSelector:@selector(viewControllerWillDismiss)]) {
254+
[self.delegate viewControllerWillDismiss];
255+
}
257256

258257
if (_parentSheetController) {
259258
if ([_parentSheetController.delegate respondsToSelector:@selector(viewControllerWillFocus)]) {
@@ -288,11 +287,13 @@ - (void)emitDidDismissEvents {
288287
- (void)viewWillDisappear:(BOOL)animated {
289288
[super viewWillDisappear:animated];
290289

291-
// Emit willDismiss only if not dragging
290+
// Dispatch to allow pan gesture to set _isDragging before checking
292291
// handleTransitionTracker will emit when sheet is transitioning to dismiss
293-
if (!_isDragging) {
294-
[self emitWillDismissEvents];
295-
}
292+
dispatch_async(dispatch_get_main_queue(), ^{
293+
if (!self->_isDragging) {
294+
[self emitWillDismissEvents];
295+
}
296+
});
296297

297298
[self setupTransitionTracker];
298299
}

0 commit comments

Comments
 (0)