React-native-swipe-list-view: Can't programatically close a row

Created on 6 Oct 2016  路  13Comments  路  Source: jemise111/react-native-swipe-list-view

I'm using a per-row configuration and am seeing some strange behaviour. I think its related to the view being updated with new rows while an existing row is a swiped state. It looks like its getting confused as to while row was in the swiped state when the model was updated. I'm not sure how to fix, but a workaround might be to programatically close all rows before the model changes - which in my case would be fine. But how do you do that?

Most helpful comment

Is it possible just using a SwipeRow?

All 13 comments

Hm @npomfret I'll have to look into this further but for now you could try keeping a ref to your SwipeListView and calling:

this.refs.swipeListView.safeCloseOpenRow()

That's a bit of a hack but it might work

Thanks for the suggestion but it didn't seem to work. I'm using per row behaviour, I think that's what's causing it to fail. In fact I noticed that onRowPress and onRowOpen in _SwipeListView.js_ aren't being called either. Maybe I've set it up wrong?

+1

+1, any news on this?

It is working for me

@jemise111 hi,is it possible to programatically open a row ?

@kingorange2309 Yes it is. Here is an example of opening a row programmatically when it is touched. You can use the manuallySwipeRow instance method on swipe rows.

<SwipeListView
    dataSource={this.ds.cloneWithRows(this.state.listViewData)}
    renderRow={(data, secId, rowId, rowMap) => (
        <TouchableHighlight
            onPress={_ => rowMap[`${secId}${rowId}`].manuallySwipeRow(75)}
            style={styles.rowFront}
            underlayColor={'#AAA'}
        >
            <View>
                <Text>I'm {data} in a SwipeListView</Text>
            </View>
        </TouchableHighlight>
    )}
    renderHiddenRow={(data, secId, rowId, rowMap) => (
        <View style={styles.rowBack}>
            <Text>Left</Text>
            <View style={[styles.backRightBtn, styles.backRightBtnLeft]}>
                <Text style={styles.backTextWhite}>Right</Text>
            </View>
            <TouchableOpacity style={[styles.backRightBtn, styles.backRightBtnRight]} onPress={_ => this.deleteRow(secId, rowId, rowMap)}>
                <Text style={styles.backTextWhite}>Delete</Text>
            </TouchableOpacity>
        </View>
    )}
    leftOpenValue={75}
    rightOpenValue={-150}
/>

@npomfret I'm trying to reproduce your issues but I can't seem to. It would be super helpful if you could post all the version information (SLV version, RN version, device platform and OS version) and the code you're using.

Also - onRowPress isn't a supported prop on the SwipeListView so that one is expected. If you want to add it, it shouldn't be a tough PR.

For me onRowOpen is working as expected.

@jemise111 yes,it worked ,thx!

Is it possible just using a SwipeRow?

@npomfret have you solve this problem?

@KingAmo sorry no, I stopped using react-native

Closing as inactive, please re open if anyone still has this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Elijen picture Elijen  路  5Comments

VitaliiK91 picture VitaliiK91  路  3Comments

benoitvallon picture benoitvallon  路  6Comments

ramisalem picture ramisalem  路  5Comments

jwilliamson-qb picture jwilliamson-qb  路  3Comments