Skip to content

Glitchy large header behavior when combaining SafeArea with Scroll #2822

@maciekstosio

Description

@maciekstosio

Large header on iOS does not feel so smooth when wrapping with SafeArea (which is required in some cases).

You should be able to see a jump when using ScrollView wrapped with SafeAreaView:

without SafeArea with SafeArea
without.SafeArea.mov
with.SafeArea.mov
Source code:
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { ScrollView, Text, View, SafeAreaView } from 'react-native';
import {
  createNativeStackNavigator,
} from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

export default function NativeNavigation() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen
          name="Home"
          component={Home}
          options={{
            headerLargeTitle: true,
          }}
        />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

const Card = ({text}) => (
  <View style={{
    height: 100,
    borderWidth: 1,
    borderColor: "#f0f",
    justifyContent: 'center',
    alignItems: 'center',
  }}>
    <Text style={{fontSize: 30}}>{text}</Text>
  </View>
);

export function Home() {
  const content = (
    <>
      <Card text="1" />
      <Card text="2" />
      <Card text="3" />
      <Card text="4" />
      <Card text="5" />
      <Card text="6" />
      <Card text="7" />
    </>
  );

  // ScrollView adjusted
  // return (
  //   <ScrollView contentInsetAdjustmentBehavior="automatic">
  //     {content}
  //   </ScrollView>
  // );

  // SafeAreaView with ScrollView
  return (
    <SafeAreaView>
      <ScrollView>
        {content}
      </ScrollView>
    </SafeAreaView>
  );
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe user didn't precise the problem enoughmissing-reproThis issue need minimum repro scenarioplatform:iosIssue related to iOS part of the library

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions