Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Fix refreshControl layouting #28236

Closed
wants to merge 14 commits into from

Conversation

yogevbd
Copy link
Contributor

@yogevbd yogevbd commented Mar 5, 2020

Summary

In react-native-navigation we allow the usage of native iOS navigationBar largeTitle which cause the title to "jump" when pulling to refresh.
We found that the layout calculations of the refreshControl element mess up the system behaviour.

Changelog

[iOS] [Fixed] - Fix refreshControl messes up navigationBar largeTitles

Test Plan

Before the fix:

before

And after:

after

How it looks like with react-native init app after the fix:

ezgif com-video-to-gif (4)

@facebook-github-bot
Copy link
Contributor

Hi @yogevbd!

Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Mar 5, 2020
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 5, 2020
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@analysis-bot
Copy link

analysis-bot commented Mar 5, 2020

RNTester.app (iOS): 10715136 bytes

@maxencehenneron
Copy link

maxencehenneron commented Mar 13, 2020

Thank you for the PR. However, it seems that the refreshControl property of UIScrollView is only available on iOS 10+.

see: https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol

can you wrap the assignation in an @available condition? Also, maybe keep the current code in older versions for retro compatibility?

Edit: nevermind, react-native 0.62 targets iOS 10.0. I didn't know about this change, looks good!

My app uses large title (without react-native-navigation) and suffers the same issue.

@shergin
Copy link
Contributor

shergin commented Mar 22, 2020

I think we dropped support for iOS 9 in January, so that should be possible to land. I will be oncall next week, so I will try to land it today.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@shergin shergin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compilation fails with:

stderr: xplat/js/react-native-github/React/Views/ScrollView/RCTScrollView.m:233:23: error: incompatible pointer types assigning to 'UIRefreshControl * _Nullable' from 'UIView *' [-Werror,-Wincompatible-pointer-types]
self.refreshControl = refreshControl;
^ ~~~~~~~~~~~~~~

@yogevbd
Copy link
Contributor Author

yogevbd commented Mar 24, 2020

@shergin The build should pass now. Can you please review? Thanks!

@analysis-bot
Copy link

analysis-bot commented Apr 1, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 41fb336

@analysis-bot
Copy link

analysis-bot commented Apr 1, 2020

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 6,765,381 0
android hermes armeabi-v7a 6,433,045 0
android hermes x86 7,153,229 0
android hermes x86_64 7,043,118 0
android jsc arm64-v8a 8,936,764 0
android jsc armeabi-v7a 8,596,806 0
android jsc x86 8,767,718 0
android jsc x86_64 9,343,239 0

Base commit: 41fb336

@guyca
Copy link

guyca commented Apr 2, 2020

Only the windows tests suite fails. I'm assuming it's flaky since this PR was rebased yesterday and other builds are passing. Could someone please trigger the failing tests suite? 🙏 @shergin

@guyca
Copy link

guyca commented Apr 20, 2020

@shergin Tests are green! 💚

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@guyca
Copy link

guyca commented Jul 26, 2020

LGTM! 🔥

@yogevbd
Copy link
Contributor Author

yogevbd commented Jul 26, 2020

@shergin @PeteTheHeat Can you guys please try to merge it again?

@simonmitchell
Copy link

Whoop whoop! Great work guys, excited to see this merged as it's now patched in two of our projects 😝

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeteTheHeat has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@Evan-Younan
Copy link

Thanks a lot for this fix! Looking forward to seeing this merged soon.

@chrise86
Copy link

Has this made it into a release yet?

@chrise86
Copy link

@simonmitchell @yogevbd tried this out using a patch, and the refresh indicator works great now. I have noticed a couple odd jumps on load sometimes, where the title appears small to start and the content appears under the navbar, but generally much better. However it looks like this has broken stickyHeaderIndices, or at least the content inset calculation for it. Content now hides under the navbar when scrolled.

@guyca
Copy link

guyca commented Sep 25, 2020

@chrise86
Since it's a bit difficult to reproduce edge cases reported in issues - would you be able to push a minimal reproducible example?

@julian-baumann
Copy link

What is the current status on this?

Btw @yogevbd how did you manage to apply a transparent background to a large title only with react native navigation? And also remove the border.

@yogevbd
Copy link
Contributor Author

yogevbd commented Oct 19, 2020

@julian-baumann These options should do with react-native-navigation:

{
  topBar: {
    background: {
      color: 'transparent',
      noBorder: true
    }
  }
}

@brmk
Copy link

brmk commented Nov 26, 2020

What is the plan for releasing this? It looks abandoned, doesn't it?

@habovh
Copy link
Contributor

habovh commented Dec 15, 2020

Well according to this commit details 1b0fb9b it looks like this fix will be part of React Native 0.64 (currently in RC1).

facebook-github-bot pushed a commit that referenced this pull request Mar 11, 2021
Summary:
Fixes #30912
Reverts #31024 which did not fix the issue

This fix was removed in #28236, however it caused bug #7976 to resurface, as reported in #30912

Pull Request resolved: #30978

Test Plan:
This code had been present for quite some time before being removed in #28236

## Changelog

[Internal] [fixed] - regression with refresh control

Reviewed By: p-sun

Differential Revision: D26981600

Pulled By: PeteTheHeat

fbshipit-source-id: 2560e7dba1cfd6ed41d98f2c9ff4cd07a0e5fa24
@pouyarezvani
Copy link

Was this fix released? because I'm still having this issue with the large header and FlatList RefreshControl.
If not I will need to Patch-Package it?

@dandre-hound
Copy link

@yogevbd we are discussing in #31461 how this PR introduces an undesirable visual jump when pulling to refresh on RN list components (scrollview, flatlist, and sectionlist). We are able to reproduce the visual jump on fresh react-native projects with and without navigation headers. After reverting this PR, pulling to refresh is smooth as expected. Do you have any pointers as to why this may be happening, especially since we're able to reproduce without navigation headers? We're really surprised more people haven't mentioned #31461 since it's easily reproducible and it's a very obvious UI issue.

Do you think we're safe to rollback this commit locally if we don't use large navigation headers? Or does this PR fix multiple issues with pulling to refresh? If this PR is only intended to fixe this one issue with pull to refresh on large header titles, we may roll this back locally. Thanks.

@yogevbd
Copy link
Contributor Author

yogevbd commented Aug 3, 2021

@dandre-hound it is safe to rollback this commit if you don't use navigation large headers. Will work on a fix asap.

@dandre-hound
Copy link

Sounds great @yogevbd -- we are happy to help test. Thank you for offering to look into this!

@tj-mc
Copy link

tj-mc commented Jun 19, 2024

Is anybody working on a fix for the bug introduced by this PR?
We still face this issue, and are anxious to revert a many-years-old patch 🤔

Edit, sorry for the false alarm. It is actually working fine on 0.73 for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: RefreshControl Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.