Footer rendered at the bottom of the content view #645
Replies: 1 comment 2 replies
-
|
It's a recycled-view race (on 3.10.0, and still present on I can't reproduce it easily myself, but it shows up in our prod user reports and stopped after applying the patch below. Fix: stash the height as Full patchdiff --git a/ios/TrueSheetFooterView.mm b/ios/TrueSheetFooterView.mm
--- a/ios/TrueSheetFooterView.mm
+++ b/ios/TrueSheetFooterView.mm
@@ -21,6 +21,7 @@
@implementation TrueSheetFooterView {
CGFloat _lastHeight;
+ CGFloat _pendingHeight;
BOOL _didInitialLayout;
NSLayoutConstraint *_bottomConstraint;
CGFloat _currentKeyboardOffset;
@@ -38,6 +39,7 @@
self.backgroundColor = [UIColor clearColor];
_lastHeight = 0;
+ _pendingHeight = 0;
_didInitialLayout = NO;
_bottomConstraint = nil;
_currentKeyboardOffset = 0;
@@ -50,6 +52,11 @@
- (void)setupConstraintsWithHeight:(CGFloat)height {
UIView *parentView = self.superview;
if (!parentView) {
+ // On recycled views, updateLayoutMetrics can fire before the view is
+ // reparented. Remember the desired height so didMoveToSuperview applies
+ // it instead of falling back to the stale self.frame from the previous
+ // present cycle.
+ _pendingHeight = height;
return;
}
@@ -70,13 +77,14 @@
}
_lastHeight = height;
+ _pendingHeight = 0;
}
- (void)didMoveToSuperview {
[super didMoveToSuperview];
if (self.superview) {
- CGFloat initialHeight = self.frame.size.height;
+ CGFloat initialHeight = _pendingHeight > 0 ? _pendingHeight : self.frame.size.height;
[self setupConstraintsWithHeight:initialHeight];
}
}
@@ -105,6 +113,7 @@
}
_lastHeight = 0;
+ _pendingHeight = 0;
_didInitialLayout = NO;
_bottomConstraint = nil;
_currentKeyboardOffset = 0; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
A few (too many unfortunately) of my users are experiencing an issue where the footer gets rendered at the bottom of the sheet content instead of the bottom of the sheet. I cannot reproduce it myself, so I wanted to ask if anyone else have experienced this themselves or got reports from their users about it so I can reproduce it before creating an issue.
This is basically how it looks:

The height for the footer is still reserved and the sheet has the correct height (we use fixed detent in this case and not auto) but the footer is rendered with its bottom at the bottom of the content view. The footer height is fixed height when opening the sheet and I have also tried passing that fixed height as footerProps and the issue is still there.
I use the latest version 3.10.0.
Beta Was this translation helpful? Give feedback.
All reactions