Skip to content

[Android] Missing title and an extra space appear when using RTL #3438

@kkosobudzki

Description

@kkosobudzki

Description

In RTL mode, if headerTitleAlign is set to center and headerTitle is defined as a function, the title isn’t displayed and the header gains extra spacing.

<Stack.Navigator 
    screenOptions={{
      headerTitle: () => (
        <View>
          <Text>Elo elo</Text>
        </View>
      ),
      headerRight: () => (
        <View>
          <Text>Right</Text>
        </View>
      ),
      headerTitleAlign: 'center',
    }}
  >
  (...)
  </Stack.Navigator>

rtl no title

Interestingly, using a string for headerTitle makes the header render properly in RTL as well.

  <Stack.Navigator 
    screenOptions={{
      headerTitle: 'Elo elo',
      headerRight: () => (
        <View>
          <Text>Right</Text>
        </View>
      ),
      headerTitleAlign: 'center',
    }}
  >
  (...)
  </Stack.Navigator>

rtl with static title

On the other hand, header is rendered properly with both types in LTR.

ltr works fine

Steps to reproduce

  • Use native stack navigator with headerTitleAlign: 'center' and pass a function toheaderTitle
  • Use RTL

Snack or a link to a repository

https://github.com/kkosobudzki/rtl-navigation

Screens version

4.18.0

React Native version

0.82.1

Platforms

Android

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidThis issue is specific to AndroidRepro providedA reproduction with a snack or repo is provided

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions