MobileReality / react-native-select-pro

React Native dropdown (select) component developed by Mobile Reality
https://mobilereality.github.io/react-native-select-pro
MIT License
299 stars 18 forks source link

[BUG] Wrong options list `top` value on Android #215

Closed efstathiosntonas closed 1 year ago

efstathiosntonas commented 1 year ago

APPROX_STATUSBAR_HEIGHT seems to provide wrong top position of the options list container on Android. On iOS it works fine since it's always 0 on versions > 11.

https://github.com/MobileReality/react-native-select-pro/blob/6a9ac023cf0bbb25027f466503a9a05cec003dd3/packages/react-native-select-pro/src/components/select/select.hooks.ts#L82

With APPROX_STATUSBAR_HEIGHT:

Screenshot 2023-05-30 at 12 42 45

Without APPROX_STATUSBAR_HEIGHT:

Screenshot 2023-05-30 at 12 42 25

Environment:

gitsad commented 1 year ago

Hi @efstathiosntonas

It might be a react native issue as it's fetched from RN API.

import { NativeModules, Platform } from 'react-native';

// based on: https://github.com/callstack/react-native-paper/blob/main/src/constants.tsx
const statusBarHeight =
    NativeModules.NativeUnimoduleProxy?.modulesConstants?.ExponentConstants?.statusBarHeight ?? 0;

export const APPROX_STATUSBAR_HEIGHT: number = Platform.select({
    android: statusBarHeight,
    ios: Platform.Version < 11 ? statusBarHeight : 0,
});

Have you tried to find out other proper calculations of the height of the status bar on Android? Also, could you provide a repo with a reproduction of this issue?

efstathiosntonas commented 1 year ago

May I ask why this is needed? Is it needed for the Portal to properly calculate it's position?

I'll fork one of the expo examples and try to reproduce it.

You could get the status bar height for android from https://reactnative.dev/docs/statusbar#currentheight-android or use an external dep like https://github.com/ovr/react-native-status-bar-height

kkaplinski commented 1 year ago

Hey @efstathiosntonas can you check on the real android device ? I remember that on emulators there are some strange problems regarding to calculations of height: https://github.com/callstack/react-native-paper/issues/3568. As you can see some people have them and some have not

efstathiosntonas commented 1 year ago

@kkaplinski I’ve tried on a Samsung S22 and on a Pixel 6 emulator and the gap was there on both. I’m trying to reproduce it on an Expo snack (from docs) but I couldn’t, will try and create one locally and share it.

gitsad commented 1 year ago

HI @efstathiosntonas

@ookil has fixed it in the latest release: https://github.com/MobileReality/react-native-select-pro/releases/tag/%40mobile-reality%2Freact-native-select-pro%402.1.6