react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

LargeHeader stays small after pop/goBack/swipe gesture on iOS 14+

Open hirbod opened this issue 6 years ago • 79 comments

Hi,

I just upgraded to Expo SDK 39 and before of that, I had never an issue navigating to a child screen (from LargeHeader to small header). When I go back now, it stays smalls instead of growing back to large.

What has changed and is this something known?

hirbod avatar Sep 23 '20 14:09 hirbod

This looks like it has nothing to do with SDK 39, its an issue with iOS 14. It works on iOS 13. Here is a video @WoLewicki https://streamable.com/x4vo01

The same code on iOS 13 will grow the large header back to its original size.

hirbod avatar Sep 23 '20 14:09 hirbod

Yeah, I can spot problems with this. It looks like some kind of bug because it doesn't happen in the Settings of your phone. Am I right?

WoLewicki avatar Sep 23 '20 15:09 WoLewicki

@WoLewicki you are right, works great everywhere else in the system.

hirbod avatar Sep 23 '20 18:09 hirbod

The same here 👍

ArekChr avatar Sep 28 '20 11:09 ArekChr

Does this behavior appear only while using ScrollView?

WoLewicki avatar Oct 14 '20 12:10 WoLewicki

For me, it happens when using ScrollView and FlatList

hirbod avatar Oct 14 '20 12:10 hirbod

Maybe this is related: iOS 14 Large title collapse when app run firstly.

I experience this issue too, when I start the app or scroll to the top, navigate and go back on iOS 14.

julian-baumann avatar Oct 18 '20 14:10 julian-baumann

Can you check if #670 fixes the issue and does not introduce any new issues?

WoLewicki avatar Oct 19 '20 10:10 WoLewicki

I’ve got the same problem on my Navigation router (@WoLewicki your fix didn’t work for me).

I’ve worked out a fix but we need to tweak the RCTScrollContentView class in React Native. We must ensure that updateContentOffsetIfNeeded first runs after the ScrollView is moved to the window. So we prevent it running inside reactSetFrame if there’s no window yet and get it to run from didMoveToWindow instead.

Here’s the fixed RCTScrollContentView. Can you check it works for you, please? You can open your project in XCode and paste this code into RCTScrollContentView

@implementation RCTScrollContentView

- (void)didMoveToWindow
{
    [super didMoveToWindow];
    RCTScrollView *scrollView = (RCTScrollView *)self.superview.superview;
    [scrollView updateContentOffsetIfNeeded];
}

- (void)reactSetFrame:(CGRect)frame
{
  [super reactSetFrame:frame];

  RCTScrollView *scrollView = (RCTScrollView *)self.superview.superview;

  if (!scrollView || !self.window) {
    return;
  }

  RCTAssert([scrollView isKindOfClass:[RCTScrollView class]], @"Unexpected view hierarchy of RCTScrollView component.");

  [scrollView updateContentOffsetIfNeeded];
}

@end

grahammendick avatar Oct 19 '20 14:10 grahammendick

Looks like it works @grahammendick :tada:. Are you going to submit a PR with this in the react-native repository?

WoLewicki avatar Oct 19 '20 14:10 WoLewicki

@WoLewicki I'm glad it works for you too! I don't really like submitting PRs in the react-native repo. It takes me a while to set everything up to run locally and then they never look at the PR anyway. I'm happy for someone on this issue to submit the PR instead if they want

grahammendick avatar Oct 19 '20 14:10 grahammendick

I agree with @grahammendick on this. If you're an unknown name in the original react-native repo, PRs won't get a merge in years. Super frustrating to submit something there. I don't know how many times I tried to get their (facebook) eyes on broken scroll-to-top behaviour on inverted scrollviews.

I think, you guys from SWM have a better reputation and are more likely to have success submitting something there.

Is there a chance to fix this trough react-native-screens instead of fixing it upstream? @WoLewicki

hirbod avatar Oct 19 '20 15:10 hirbod

I tried fixing it upstream in my Navigation router but had no luck. The problem is we need to stop the updateContentOffsetIfNeeded running in reactSetFrame because that's too early. You can see what I mean by commenting out the !self.windowcheck in the fix and see it doesn't work anymore

grahammendick avatar Oct 19 '20 15:10 grahammendick

@Hirbod You're right, but the react-native repo is just one example of the problems you have if you're an unknown name in React. I've found it impossible to get my work looked at. If you're not a name then you're not getting in

grahammendick avatar Oct 19 '20 15:10 grahammendick

@WoLewicki can someone from your team create PR to react-native repository?

ArekChr avatar Oct 19 '20 17:10 ArekChr

It would need more debugging, submitting a PR with changes to a component used by almost every developer must have a very strong explanation and must ensure that no right behavior will be broken after it.

WoLewicki avatar Oct 20 '20 09:10 WoLewicki

For me, this quick hack worked.

return(

      <FlatList
           contentOffset={{ x: 0, y: -1}}
                contentInsetAdjustmentBehavior={"always"}
                maintainVisibleContentPosition={
                    {

                        autoscrollToTopThreshold: -1,
                        minIndexForVisible: -1
                    }
                }
       > 
          {/*your content goes here */}
       </FlatList>
)

DasArthur avatar Oct 31 '20 16:10 DasArthur

@DasArthur in my test cases, it looks like there is some race condition and it sometimes loads initially a large header and sometimes a small one. Can you check this solution @ArekChr @grahammendick ?

WoLewicki avatar Nov 02 '20 10:11 WoLewicki

I remember trying a variety of contentOffset and contentInset and repeatedly reloading - sometimes it worked and sometimes it didn't. My guess is that the times it worked is when the reactSetFrame was called after it was added to the window - @DasArthur Could you check if the timing of the reactSetFrame changes when it works and when it doesn't? Or does it always work for you every time you reload?

grahammendick avatar Nov 02 '20 10:11 grahammendick

I don't have maintainVisibleContentPosition prop, @DasArthur what version of RN are you using?

ArekChr avatar Nov 02 '20 10:11 ArekChr