react-native-modal-dropdown icon indicating copy to clipboard operation
react-native-modal-dropdown copied to clipboard

Wrong position calculation when modal is dropped down

Open 000xuandu opened this issue 6 years ago • 4 comments

I am using "react-native-modal-dropdown": "^ 0.7.0".

Currently, I encounter this problem on my android device (on IOS devices it does not happen), that is: When the modal is dropped down, the position between the "Select Topic" button and the modal is spaced apart.

Code and error are posted in the image: viber_image_2019-11-04_10-22-28 viber_image_2019-11-04_10-24-40

Expected: The position of this modal is right below the "Select Topic" button.

@ajonno Help me, pls

000xuandu avatar Nov 04 '19 03:11 000xuandu

I think the problem is here: https://github.com/sohobloo/react-native-modal-dropdown/blob/master/components/ModalDropdown.js#L217

Should be, frameStyle, dropdownStyle instead of dropdownStyle, frameStyle Please guide me on how to fix the error. I hope you.

000xuandu avatar Nov 05 '19 03:11 000xuandu

@000xuandu I had this problem too. I think it may have been caused by one of the flex style props passed to the ModalDropdown container.

You can solve it by subtracting from the top style prop in the handler like this:

<ModalDropdown
  options={['option 1', 'option 2']}
  adjustFrame={style => {
    style.top = style.top - 15;
    return style;
  }}
/>

GavinRay97 avatar Dec 05 '19 18:12 GavinRay97

Android function measure will add the height of the status bar you can resolve it subtract it in the adjustFrame prop like this:

<ModalDropdown
  options={['option 1', 'option 2']}
  adjustFrame={style => {
    style.top =(Platform.OS === 'ios' ? style.top : style.top - StatusBar.currentHeight);
    return style;
  }}
/>

Luanluu96 avatar Feb 12 '20 09:02 Luanluu96

Android function measure will add the height of the status bar you can resolve it subtract it in the adjustFrame prop like this:

<ModalDropdown
  options={['option 1', 'option 2']}
  adjustFrame={style => {
    style.top =(Platform.OS === 'ios' ? style.top : style.top - StatusBar.currentHeight);
    return style;
  }}
/>

you save my life, many thanks

tz211488 avatar Oct 26 '22 15:10 tz211488