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

FormSheet fitToContents doesn't work on iOS - Opens full screen #2665

Closed
Eli-Nathan opened this issue Feb 3, 2025 · 3 comments · Fixed by #2670
Closed

FormSheet fitToContents doesn't work on iOS - Opens full screen #2665

Eli-Nathan opened this issue Feb 3, 2025 · 3 comments · Fixed by #2670
Assignees
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@Eli-Nathan
Copy link

Eli-Nathan commented Feb 3, 2025

Description

Very excited to see formSheets!

When using formSheet screens and applying the fitToContents options on sheetAllowedDetents it only ever opens a full modal screen on iOS, similar to if I was to apply sheetAllowedDetents: [1]. Android appears to work as expected here.

I see issue #2521 mentions the example app and the fix you applied is to remove the flex: 1 style from the screen but that doesn't seem to help.

Also, something that would be very helpful would be the option to apply [-1, 0.5, 1] to sheetAllowedDetents to first use the content height, then allow it to expand to a full screen sheet. I'll raise a feature request separately for that though.

Steps to reproduce

  1. Add a formSheet Screen with a small amount of content
  2. Apply sheetAllowedDetents: "fitToContents" to screen options
  3. Open sheet on Android
    3.1. Opens at the correct height
  4. Open sheet on iOS
    4.1. Opens as a full screen modal

Image

See Stack link below for details

Snack or a link to a repository

https://snack.expo.dev/@eli-nathan/formsheet

Screens version

4.6.0

React Native version

0.77.0

Platforms

iOS, Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 15

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS labels Feb 3, 2025
@kkafar kkafar self-assigned this Feb 3, 2025
@kkafar
Copy link
Member

kkafar commented Feb 3, 2025

I kinda confirm the issue 😅 If you pass headerShown: false to the screen with form sheet - it'll work.

If there is header present there indeed will be a bug. I should be able to fix this today. Thanks for the report!

@Eli-Nathan
Copy link
Author

That does work! 🎉 Thanks for the quick response!

@kkafar
Copy link
Member

kkafar commented Feb 4, 2025

Glad to hear. But fixing the issue completely won't be so straightforward as I've thought initially.

kkafar added a commit that referenced this issue Feb 5, 2025
…ts` (#2670)

## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
2 participants