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 with sheetAllowedDetents: 'fitToContents' doesn't update height dynamically on Android #2560

Open
SickanK opened this issue Dec 9, 2024 · 5 comments
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@SickanK
Copy link

SickanK commented Dec 9, 2024

Description

The new native stack presentation formSheet with sheetAllowedDetents: 'fitToContents' on Android initially works correctly by adjusting to the content height. However, when the content height changes dynamically, the sheet does not update its height to match.

I had a short interaction over on X and was directed to post an issue here. Love the new formSheets, looking forward to being able to use them with dynamic height adjustment!

Steps to reproduce

  1. Create a new screen with a formSheet presentation mode and sheetAllowedDetents set to fitToContents
  2. Add content with a fixed height to the formSheet
  3. Open the formSheet from another screen
  4. Verify that the initial sheet height matches the fixed content height correctly
  5. Change the content's fixed height programmatically
  6. Observe that the sheet height remains at its initial size and does not adjust to match the new content height

Snack or a link to a repository

https://snack.expo.dev/SnPwLOzeISrX17ay1RuQY

Screens version

4.1.0

React Native version

0.76.3

Platforms

Android

JavaScript runtime

JSC

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Real device

Device model

Nothing Phone (2) (Android 14)

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 labels Dec 9, 2024
@ljukas
Copy link

ljukas commented Dec 9, 2024

I heavily use https://github.com/lodev09/react-native-true-sheet for my sheets and they have the same issue regarding auto-sized sheets on Android. How to work around it there is that you also give the largest possible detent as an available size. So you would give ['fitToContents', '1.0'] or similar. This might work here to.

@kkafar
Copy link
Member

kkafar commented Dec 10, 2024

My first impression is that it should be straightforward to do. Gimme few minutes

@kkafar
Copy link
Member

kkafar commented Dec 10, 2024

I can make it jump to the right height, but I can't animate it properly (I don't want to animate it manually, would prefer to delegate it to the bottom sheet behaviour). Will look into it some more

@kkafar
Copy link
Member

kkafar commented Dec 11, 2024

Here's PoC of the changes: #2570

I wonder how it should work in cases where the content disappears? When you remove the view it would disappear instantly (unless you use reanimated or something) reducing the sheet size - animating in such cases would not make much sense.

Maybe better way forward would be to expose the sheet position as some kind of animated value you would be able to animate?

@SickanK
Copy link
Author

SickanK commented Dec 13, 2024

Thanks for working on this!

Wouldn't the expected behavior mirror what happens when you initially open a sheet without content? What cases would the content disappear where you wouldn't want to instead e.g. close the sheet?

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 Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

3 participants