Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): wrong height of formSheet in nested stack with fitToContents #2670

Merged
merged 9 commits into from
Feb 5, 2025

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Feb 5, 2025

Description

Closes #2665

In case when we present formSheet with header, the content is nested in another stack -> content wrapper is not mounted directly under presented screen --> we need to forward information of content dimensions from nested content wrapper to the screen with formSheet presentation.

Due to order of updates on Fabric (bottom up assembling of the host tree) first moment when we can look for ancestor screen with formSheet presentation is when we move to window...
And that is what I did. Now RNSScreenContentWrapper looks for appropriate screen to attach to in willMoveToWindow.

There was another problem: any stack along the way impacts desired height of the sheet -> therefore while looking for appropriate screen the wrapper sums up heights of encountered navigation bars and gives that information to the screen.

Important

using formSheet with header enabled could lead to flicker (we won't be able to solve it for now, until we are able to trigger react commit & layout synchronously). Maybe we should describe this in types?

Changes

☝🏻

Test code and steps to reproduce

TestFormSheet + set headerShown: true on formSheet screen.

Checklist

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

@kkafar kkafar changed the title fix(iOS, Fabric): wrong height of formSheet in nested stack with fitToContents fix(iOS): wrong height of formSheet in nested stack with fitToContents Feb 5, 2025
Copy link
Member Author

@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.

Solid 😄

@kkafar kkafar merged commit 51a1488 into main Feb 5, 2025
5 checks passed
@kkafar kkafar deleted the @kkafar/2665-fittocontents-ios branch February 5, 2025 15:33
kkafar added a commit that referenced this pull request Feb 11, 2025
…ew from content wrapper (#2683)

## Description

In #2670 I've added a check that logged RN error in case
`contentWrapper.reactSuperview` is not a `RNSScreenView`.
Now I got reports (but no reproduction :/) from two independent sources
that this error is triggered pretty often,
which is unexpected from my perspective. I blindly blame view flattening
/ usage of legacy navigators but can not be sure.

This PR is an attempt to patch this behaviour.

## Changes

contentWrapper now searches whole view ancestor chain before logging an
error.

## Test code and steps to reproduce

No reproducer :/ 

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
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.

FormSheet fitToContents doesn't work on iOS - Opens full screen
1 participant