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

Issue with using FlatList in Modal - Layout issue #148

Closed
tomleeshihhung opened this issue Apr 25, 2018 · 11 comments
Closed

Issue with using FlatList in Modal - Layout issue #148

tomleeshihhung opened this issue Apr 25, 2018 · 11 comments
Labels

Comments

@tomleeshihhung
Copy link

tomleeshihhung commented Apr 25, 2018

Normally, the height of FlatList can be controlled by wrapping it with the react native
However, it doesn't appear to work here.

The FlatList disregards the boundaries set by and the rows continue on.
Interestingly, if I make the FlatList horizontal, it works just fine.

Any ideas? Thank you

Below is the code for the Modal component.

<
Modal isVisible={visible}
animationIn='slideInUp'
backdropOpacity={0.5}
style={{ margin: 15 }}>

<
View style={{ height: 300 }}>
<
FlatList
data={data}
renderItem={modalBenefitItem}
keyExtractor={(item) => item.key}
scrollEnabled/>

<
/View>
<
/Modal>

@landandan
Copy link

me too

@mmazzarolo
Copy link
Member

Could you share a simple repo with the issue?

@zmfang
Copy link

zmfang commented Jul 25, 2018

So?How can I solve it?

@GreatAuk
Copy link

GreatAuk commented Nov 1, 2018

+1

5 similar comments
@Donhv
Copy link

Donhv commented Jan 3, 2019

+1

@Josin22
Copy link

Josin22 commented Nov 2, 2019

+1

@boss225
Copy link

boss225 commented Dec 2, 2019

+1

@thedeg123
Copy link

+1

@alicema15
Copy link

+1

@sometimescasey
Copy link

sometimescasey commented Dec 3, 2020

Can confirm I'm experiencing this right now as well, with Expo 38.

Inside the Modal I can set a View with style={{flex:1}} or style={{height:300}}, but if I use a FlatList inside this View, the list content begins scrolling from the bottom of the screen, not the bottom of the Modal.

Making a note here in case anyone finds a solution.


Edit: nvm...the solution to my specific issue was surprisingly simple: set style={{flex:1}} on the FlatList itself as well. Not sure if this was OP's issue, but this gets the FlatList to scroll from the bottom of the Modal as intended:

import RNModal from 'react-native-modal';
...
<RNModal isVisible={this.state.showModal}>
    <View style={styles.modal}>
        <FlatList style={{flex: 1}} ... />
    </View>
</RNModal>

and styles.modal for reference:

modal: {
        flex: 1,
        backgroundColor: 'white',
        opacity: 1,
        padding: 20,
        borderRadius: 10,
    },

@CMDezz
Copy link

CMDezz commented Jul 21, 2023

@sometimescasey You saved my day at 2AM. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests