react-native-material-dialog icon indicating copy to clipboard operation
react-native-material-dialog copied to clipboard

ScrollView inside MaterialDialog doesn't scroll

Open peacechen opened this issue 7 years ago • 2 comments

Code snippet:

<MaterialDialog
	visible={this.state.isVisible}
	okLabel={'OK'}
	onOk={this.closeModal}
	onCancel={this.closeModal}
	scrolled={true}
>
	<ScrollView>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		<Text style={{padding: 100}}>Lorem ipsum ....</Text>
	</ScrollView>
</MaterialDialog>

The View containing the children should set onStartShouldSetResponder , as detailed in this SO: https://stackoverflow.com/questions/33060859/react-native-touchable-is-disabling-scrollview

Tested the fix and it works well. I'll submit a PR.

peacechen avatar Aug 30 '18 18:08 peacechen

An alternative solution which doesn't require changes to this library is to wrap the children within the ScrollView. The View is given the prop onStartShouldSetResponder which tells it to pass up the touch-start event to the ScrollView.

It may be helpful to document this in the Readme.

<MaterialDialog
	visible={this.state.isVisible}
	okLabel={'OK'}
	onOk={this.closeModal}
	onCancel={this.closeModal}
	scrolled={true}
>
	<ScrollView>
		<View  onStartShouldSetResponder={() => true}>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
			<Text style={{padding: 100}}>Lorem ipsum ....</Text>
		</View>
	</ScrollView>
</MaterialDialog>

peacechen avatar Sep 25 '18 20:09 peacechen

Github

this Line be changed const { height } = Platform.OS == 'android' ? Dimensions.get('window') : Dimensions.get('screen');

akwebengineer26 avatar Mar 02 '20 17:03 akwebengineer26