Closed RenanSanguinete closed 2 years ago
I don't know if this is the right way to do it but it solve the scroll issue on long lists :)
edit this file node_modules\react-native-material-menu\src\menu.js
...
import {
Animated,
Dimensions,
Easing,
Modal,
Platform,
StatusBar,
StyleSheet,
TouchableWithoutFeedback,
View,
ViewPropTypes,
I18nManager,
ScrollView, //ADD THIS
} from 'react-native';
...
render() {
...
return (
<View ref={this._setContainerRef} collapsable={false} testID={testID}>
<View>{button}</View>
<Modal
visible={modalVisible}
onRequestClose={this._hide}
supportedOrientations={[
'portrait',
'portrait-upside-down',
'landscape',
'landscape-left',
'landscape-right',
]}
transparent
onDismiss={this._onDismiss}
>
<TouchableWithoutFeedback onPress={this._hide} accessible={false}>
<View style={StyleSheet.absoluteFill}>
<Animated.View
onLayout={this._onMenuLayout}
style={[
styles.shadowMenuContainer,
shadowMenuContainerStyle,
style,
]}
>
<Animated.View
style={[styles.menuContainer, animationStarted && menuSize]}
>
<ScrollView> //ADD THIS
{children}
</ScrollView> //ADD THIS
</Animated.View>
</Animated.View>
</View>
</TouchableWithoutFeedback>
</Modal>
</View>
);
...
and add maxHeight
to Menu
style:
<Menu
style={{maxHeight: 300}}
>
...
</Menu>
I don't know if this is the right way to do it but it solve the scroll issue on long lists :) edit this file
node_modules\react-native-material-menu\src\menu.js
... import { Animated, Dimensions, Easing, Modal, Platform, StatusBar, StyleSheet, TouchableWithoutFeedback, View, ViewPropTypes, I18nManager, ScrollView, //ADD THIS } from 'react-native'; ... render() { ... return ( <View ref={this._setContainerRef} collapsable={false} testID={testID}> <View>{button}</View> <Modal visible={modalVisible} onRequestClose={this._hide} supportedOrientations={[ 'portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right', ]} transparent onDismiss={this._onDismiss} > <TouchableWithoutFeedback onPress={this._hide} accessible={false}> <View style={StyleSheet.absoluteFill}> <Animated.View onLayout={this._onMenuLayout} style={[ styles.shadowMenuContainer, shadowMenuContainerStyle, style, ]} > <Animated.View style={[styles.menuContainer, animationStarted && menuSize]} > <ScrollView> //ADD THIS {children} </ScrollView> //ADD THIS </Animated.View> </Animated.View> </View> </TouchableWithoutFeedback> </Modal> </View> ); ...
and add
maxHeight
toMenu
style:<Menu style={{maxHeight: 300}} > ... </Menu>
I don't know if this is the better solution, but it works like a charm.
Thanks a lot!
You can simply achieve it by adding scrollview to the selection like this in your code instead of editing node_modules\react-native-material-menu\src\menu.js
<Menu
style={{maxHeight: 300}}
>
<ScrollView>
{ MenuItems }
</ScrollView>
</Menu>
This issue can be repeated #40, but the other one doesn't show the answer.
Is possible to scroll on long MenuItem list?
Example: