Skip to content

Wrong headerTitle layout when pushing screen with keyboard on new arch #2232

@janicduplessis

Description

@janicduplessis

Description

When pushing a new screen that has headerTitle, headerRight and an autoFocus TextInput the layout of the headerTitle is incorrect the 2nd time the screen is opened.

Workaround:

Disable view recycling in RNSScreenStackHeaderSubview

// RNSScreenStackHeaderSubview.mm

+ (BOOL)shouldBeRecycled
{
  return NO;
}

Not sure if it would be an acceptable fix, but disabling view recycling does fix the problem.

Steps to reproduce

Using this code in FabricExample app HeaderOptions.tsx

Note: If using iOS simulator make sure to toggle the software keyboard.

  • Go to "Header Options" example
  • Click the "Header large item" button
  • Click "Go to next screen"
  • See that header title layout is correct
  • Click on the navbar back icon
  • Click "Go to next screen"
  • See that the header title layout is not incorrect and offset to the right

First open:

image

2nd open:

image

Weirdly this doesn't repro if no headerRight is set or if the keyboard is not opened.

Snack or a link to a repository

https://github.com/janicduplessis/react-native-screens/tree/%40janic/header-bug-2

Screens version

main@e5a6220

React Native version

0.74

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

Labels

NewArchIssues related only to new architecturePlatform: iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is provided

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions