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.46k stars 121 forks source link

Additional space added in modal #222

Closed tarekhassan410 closed 7 months ago

tarekhassan410 commented 1 year ago

Action sheet shows additional space in bottom of it. It is random,one time it shows and the next time it doesn't.

Screenshot_20220925-120042_1 Screenshot_20220925-120106_1

ammarahm-ed commented 1 year ago

Hi, this happens on iOS or android? Also which version of the sheet are you using?

tarekhassan410 commented 1 year ago

I am using Android, version 0.8.7. Also, on downgrading to 0.8.0 it works fine.

TheAhmadSami commented 1 year ago

Did you find a solution?!, I have the same problem with version 0.8.8 using android 11 Sometimes I get padding at the bottom of the modal when using safeArea!! @tarekhassan410 @ammarahm-ed

guygolanIL commented 1 year ago

happens to me aswell on android (action sheet v: ^0.8.7)

guygolanIL commented 1 year ago

just rolled back a few versions. this started to occure on 0.8.4 @ammarahm-ed but sadly i cant remain in those builds since those have issues with react-navigation so a workaround would be appreciated

guygolanIL commented 1 year ago

also, setting a custom height following seems to mitigate that <ActionSheet id={props.sheetId} containerStyle={{ height: '15%' }}

ammarahm-ed commented 1 year ago

Try v0.8.9

tarekhassan410 commented 1 year ago

It is still happening, less often but still happening

ammarahm-ed commented 1 year ago

Have you tried v0.8.10? Also are you testing on emulator or real device?

tarekhassan410 commented 1 year ago

I am testing on emulator. It is still happening. It is better now but still happening.

guygolanIL commented 1 year ago

testing 0.8.10 on an android device and could not reproduce this bug

younes0 commented 1 year ago

I encounter this bug the getPaddingBottom() is responsible for this extra padding, it returns StatusBar.currentHeight. Why would you have bottom padding based on StatusBar.currentHeight ?

ammarahm-ed commented 1 year ago

@younes0 which version are you on?

younes0 commented 1 year ago

@ammarahm-ed latest: 0.8.17 This behavior was found on Android, not on web. I didn't test on iOS

ammarahm-ed commented 1 year ago

Can you share what your sheet is like?what styles & props you have added etc, so i can reproduce it locally 🤔@younes0

younes0 commented 1 year ago

@ammarahm-ed I use Expo btw I emoved all props and used a clean setup. But let me try with a blank expo template soon.

younes0 commented 1 year ago

@ammarahm-ed This behavior happens since 0.8.4 Check this snack, run on Android, and simply change the version to 0.8.3 and 0.8.4: https://snack.expo.dev/@younes0/github.com-ammarahm-ed-react-native-actions-sheet:expo-example

Checked https://github.com/ammarahm-ed/react-native-actions-sheet/compare/v0.8.3...v0.8.4 But can't figure out.

ammarahm-ed commented 1 year ago

@younes0 have you tried with the latest version, it's the same?

younes0 commented 1 year ago

@ammarahm-ed yes it's the same. also note that the backdrop has the same issue (the overlay starts after this extra bottom padding)

ammarahm-ed commented 1 year ago

@younes0 Try 0.8.20. I fixed the problem now I think

younes0 commented 1 year ago

@ammarahm-ed I've just updated the snack with 0.8.20 and the problem is still there

younes0 commented 1 year ago

btw Problem happens with my real device (oneplus 10t) + emulator (pixel 6)

ammarahm-ed commented 1 year ago

After the changes i made, i am not able to reproduce it in your snack example. Before it was adding bottom padding 24 and it was bigger than usual with the Text. 🤔

younes0 commented 1 year ago

@ammarahm-ed I'm not sure to understand what you mean by reproducing the snack example: the snack has been updated so you can try it. There's no padding added or anything.

ammarahm-ed commented 1 year ago

@younes0 Try 0.8.21. The issue is related to this problem https://github.com/facebook/react-native/issues/23693#issuecomment-674644381 however I think I fixed it this time. After testing real device the issue was still there.

younes0 commented 1 year ago

Almost @ammarahm-ed ! There's no extra space this time, but it seems that there is like a negative margin, you can see that the content is cropped: https://user-images.githubusercontent.com/886042/218531748-26f9b600-771e-46b2-8bbe-11fe26f42ba2.jpg

younes0 commented 1 year ago

@ammarahm-ed just realized with this new version, if you add useBottomSafeAreaPadding , it does the same incorrect behavior of before

ammarahm-ed commented 1 year ago

Then keep that prop disabled if you don't need padding from bottom. Or manually add some padding when needed.

You can simply add some safe padding at bottom i think. I will see to it again but you need to somehow diff between devices with soft buttons and those that use gestures Using some library that gives you bottom nav bar height.

ammarahm-ed commented 1 year ago

Maybe try this and add padding to container style on bottom based on nav bar height. https://github.com/ConnectyCube/react-native-android-navbar-height

baatten commented 1 year ago

I just updated to X.21 and I see padding in the bottom?

HKH01 commented 1 year ago

My workaround is below:

import { Platform, StatusBar, useWindowDimensions } from 'react-native'
import { initialWindowMetrics, useSafeAreaInsets } from 'react-native-safe-area-context'

function useSafeSheetBottom() {
  const windowHeight = useWindowDimensions().height

  let mb = useSafeAreaInsets().bottom
  if (Platform.OS === 'android') {
    const sh = StatusBar.currentHeight
    if (Math.floor(initialWindowMetrics.frame.height) === Math.floor(windowHeight)) {
      return -sh
    }
    return sh
  }
  return mb
}

and give a margin-bottom from useSafeSheetBottom() to ActionSheet's direct child element.

kockok commented 1 year ago

I also found extra bottom space in version 0.8.21 iOS physical device.

Adding useBottomSafeAreaPadding={false} won't help.

mehdinourollah commented 1 year ago

It looks like the useBottomSafeAreaPadding={false} doesn't work on iOS on version 0.8.21 ...

moesalih commented 1 year ago

has anyone figured out the cause of the randomness? why is the behavior inconsistent? i'm on iOS on v0.8.28

baatten commented 1 year ago

I'm on version 0.8.29 and also still have the issue.

mixmaker commented 1 year ago

Is this related to the issue I'm facing? As you can see the sheet doesn't draw under the navbar

Screenshot_1680434200

carlosedof commented 1 year ago

Is this related to the issue I'm facing? As you can see the sheet doesn't draw under the navbar

Screenshot_1680434200

I'm experiencing the same issue

jonxssc commented 1 year ago

Same problem here since i upgraded react native from 0.69.9 to 0.71.7 and expo from ~46.0.21 to ~48.0.15. Currently using this packages version ^0.8.29. On every Actionsheet on ios real device and simulator is a space in the size of the phones status bar on the bottom that i cant get rid of, which pushes on full size actionsheet the handler under the actionsheet.

The actionsheet containerstyle has the background color green and my content in the actionsheet has the background color red, this shows that the problem is still there on newest react native/expo and package versions.

image

jonxssc commented 1 year ago

Turns out, 0.8.3 is the last possible version without the spacing so i am using this. As you can see in this snack (newest package version) the https://snack.expo.dev/@jonassc/github.com-ammarahm-ed-react-native-actions-sheet:expo-example on an ios device it has the spacing on bottom: image

On Android it looks like this: image

The only Platform it works currectly is on Web: image

henrhie commented 1 year ago

Downgraded to 0.8.3 and bug goes away

jonxssc commented 7 months ago

For anyone searching for a solution, removing the code i pointed at in https://github.com/ammarahm-ed/react-native-actions-sheet/pull/328 this request, should fix the weird spacing, tested it on version 0.8.29

PopBot commented 7 months ago

Thanks so much @jonxssc. Was pretty puzzled on this, but glad we found a fix.

BasitAli commented 6 months ago

@ammarahm-ed Was this resolved? I still see this on latest version 0.9.2.

image

BasitAli commented 6 months ago

My workaround is below:

import { Platform, StatusBar, useWindowDimensions } from 'react-native'
import { initialWindowMetrics, useSafeAreaInsets } from 'react-native-safe-area-context'

function useSafeSheetBottom() {
  const windowHeight = useWindowDimensions().height

  let mb = useSafeAreaInsets().bottom
  if (Platform.OS === 'android') {
    const sh = StatusBar.currentHeight
    if (Math.floor(initialWindowMetrics.frame.height) === Math.floor(windowHeight)) {
      return -sh
    }
    return sh
  }
  return mb
}

and give a margin-bottom from useSafeSheetBottom() to ActionSheet's direct child element.

This workaround works partially. I need a background color on the sheet which doesn't apply to the white area even if the margin is applied on the container style.