ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.49k stars 121 forks source link

Correct vertical position of Actionsheet #288

Closed aleberguer closed 8 months ago

aleberguer commented 1 year ago

Issue

This PR solves the issue: #254

Description

This Pull Request addresses the issue where the ActionSheet component's vertical position is not correctly calculated when the React Native screen is not the same height as the device. This occurs, for example, when the app uses Native navigation and the React Native view is shorter than the device height, causing a portion of the content to be shifted and hidden below.

The cause of the issue is that the height of the <Root /> component is hardcoded with the device height here https://github.com/ammarahm-ed/react-native-actions-sheet/blob/93cf9fc943cf9e30cbbb7d4b15a687d1f3fc040c/src/index.tsx#L939 This is not always the case since the React view can take a different height than the device's height.

To fix this issue, the index.tsx has been modified to replace the initialWindowHeight.current with 100% as the height value for the <Root /> component. This change allows the ActionSheet component to be correctly positioned regardless of the height of the React Native view.

Testing

I have tested the changes on various devices with different screen heights and confirmed that the ActionSheet component is correctly positioned every time.

Video

https://user-images.githubusercontent.com/5271876/232089881-34cf187b-a816-4657-87f6-0b42762dde16.mov

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rnas ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2023 3:39pm
ammarahm-ed commented 8 months ago

Hi, thanks for the PR, i have made these changes part of v0.9.0 PR #330. I will close this.