Skip to content

Commit 7f3f80f

Browse files
janicduplessisgrabbou
authored andcommitted
Fix RefreshControl layout when removed from window (#31024)
Summary: Since iOS 14 refresh control is sometimes visible when it shouldn't. It seems to happen when it is removed and added back to the window. This repros easily when using react-native-screens with react-navigation tabs. Inactive tabs are detached from the window to save resources. Calling endRefreshing when refresh control is added to the window fixes the layout. It will also be called on first mount where it is not necessary, but should be a no-op and didn't cause any issues. I also decided to call it for all ios versions, although it is only needed on iOS 14+ to avoid forking behavior more. ## Changelog [iOS] [Fixed] - Fix RefreshControl layout when removed from window Pull Request resolved: #31024 Test Plan: Before: https://user-images.githubusercontent.com/2677334/108666197-93ea5a80-74a4-11eb-839b-8a4916967bf8.mov After: https://user-images.githubusercontent.com/2677334/108666223-9ea4ef80-74a4-11eb-8489-4e5d257299c8.mov Reviewed By: shergin Differential Revision: D26590759 Pulled By: PeteTheHeat fbshipit-source-id: b8c06068a24446b261cbeb88ff166289724031f1
1 parent 1aa4f47 commit 7f3f80f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

React/Views/RefreshControl/RCTRefreshControl.m

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ - (void)layoutSubviews
4949
_isInitialRender = false;
5050
}
5151

52+
- (void)didMoveToWindow
53+
{
54+
[super didMoveToWindow];
55+
56+
// Since iOS 14 there seems to be a bug where refresh control becomes
57+
// visible if the view gets removed from window then added back again.
58+
// Calling endRefreshing fixes the layout.
59+
if (!_currentRefreshingState) {
60+
[super endRefreshing];
61+
}
62+
}
63+
5264
- (void)beginRefreshingProgrammatically
5365
{
5466
UInt64 beginRefreshingTimestamp = _currentRefreshingStateTimestamp;

0 commit comments

Comments
 (0)