Skip to content

Conversation

@kligarski
Copy link
Contributor

@kligarski kligarski commented Dec 17, 2025

Description

Fixes missing/misaligned center subview in header on iOS.

before after
before after

Fixes #3482.

Changes

  • limit wrapping subviews and related logic to left and right subviews only on iOS 26+ (previously, there was only an SDK macro, without runtime check)

Test code and steps to reproduce

Run Test3446 to verify that pressables are still working. To test center subview, use:

Test example
import React from 'react';
import { View, Text } from 'react-native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Colors from '../shared/styling/Colors';

function MainScreen() {
  return <View style={{ backgroundColor: 'moccasin' }} />;
}

const Stack = createNativeStackNavigator();

export default function App() {
  return (
    <Stack.Navigator>
      <Stack.Screen
        name="Main"
        component={MainScreen}
        options={{
          headerLeft: () => <Text>a</Text>,
          headerTitle: () => <Text>b</Text>,
          headerRight: () => <Text>c</Text>,
          headerBackground: () => (
            <View
              style={{
                backgroundColor: Colors.PurpleLight80,
                width: '100%',
                height: 120,
              }}
            />
          ),
        }}
      />
    </Stack.Navigator>
  );
}

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kligarski kligarski marked this pull request as draft December 17, 2025 09:22
@kligarski kligarski changed the title fix(iOS, Stack): center subview not visible in header fix(iOS, Stack): center subview not visible/misaligned in header Dec 17, 2025
@kligarski kligarski marked this pull request as ready for review December 17, 2025 09:29
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Looks good. I haven't checked the runtime, so please test it carefully & land it when you are positive it works.

@kligarski
Copy link
Contributor Author

I tested both Fabric and Paper using test provided in PR description, Test3446 and TestHeaderTitle. Did not find any regressions.

@kligarski kligarski merged commit 6978a6d into main Dec 18, 2025
6 checks passed
@kligarski kligarski deleted the @kligarski/fix-center-subview-in-header-ios branch December 18, 2025 09:13
@joaquinvaz
Copy link

joaquinvaz commented Dec 30, 2025

@kkafar Hi! please we need this on a new release to upgrade our app, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[4.19.0] iOS custom header component weird positioning

5 participants