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

Not sortable when props "order" defined #214

Open
MikeCod opened this issue Jan 14, 2021 · 1 comment
Open

Not sortable when props "order" defined #214

MikeCod opened this issue Jan 14, 2021 · 1 comment

Comments

@MikeCod
Copy link

MikeCod commented Jan 14, 2021

Hello,

I can't sort the list when I add the props "order". The bug is easily reproducible :

						<SortableList
							style={{}}
							contentContainerStyle={{padding:10}}
							scrollEnabled={false}
							data={this.state.questionnaire.questions.goals}
							sortingEnabled={true}
							order={this.state.goals_order}
							renderRow={({data, active}) => {
								return <Text style={{textAlign:'center'}}>{data}</Text>
							}}
							onChangeOrder={(nextOrder) => {
								this.setState({questionnaire:{
									...this.state.questionnaire, answers:{
										...this.state.questionnaire.answers, hobbies:{
											...this.state.questionnaire.answers.hobbies,
											[this.state.questionnaire.questions.hobbies_indoor.length*2+this.state.questionnaire.questions.hobbies_outdoor.length*2+2]: nextOrder.join('/')
								}}}});
							}}
						/>

Does anyone have a tips to solve this issue ?

@Erylennn
Copy link

Erylennn commented Feb 7, 2021

Actually, it needs to update the variable passed for "order", so in my case :

<SortableList
							style={{marginTop:40}}
							contentContainerStyle={{padding:10}}
							scrollEnabled={false}
							data={this.state.questionnaire.questions.goals}
							sortingEnabled={true}
							order={this.state.goals_order}
							renderRow={({data, active}) => {
								return <Text style={{backgroundColor:THEME.color_2, color:"white", padding:8, margin:1, textAlign:'center'}}>{data}</Text>
							}}
							onChangeOrder={(nextOrder) => {
								this.setState({goals_order: nextOrder, questionnaire:{
									...this.state.questionnaire, answers:{
										...this.state.questionnaire.answers, hobbies:{
											...this.state.questionnaire.answers.hobbies,
											[this.state.questionnaire.questions.hobbies_indoor.length*2+this.state.questionnaire.questions.hobbies_outdoor.length*2+2]: "/"+nextOrder.join('/')+"/"
								}}}});
								console.log(nextOrder);
							}}
						/>

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

No branches or pull requests

2 participants