1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-13 22:12:50 +02:00

Fixed list scroll position

This commit is contained in:
Laurent Cozic
2017-07-30 23:33:54 +02:00
parent 1a5720bd8c
commit 4761606330
2 changed files with 14 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ class NoteListComponent extends Component {
items: [],
selectedItemIds: [],
};
this.rootRef_ = null;
}
filterNotes(notes) {
@@ -65,6 +66,11 @@ class NoteListComponent extends Component {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(this.filterNotes(newProps.items)),
});
// Make sure scroll position is reset when switching from one folder to another or to a tag list.
if (this.rootRef_ && newProps.notesSource != this.props.notesSource) {
this.rootRef_.scrollTo({ x: 0, y: 0, animated: false });
}
}
render() {
@@ -73,6 +79,7 @@ class NoteListComponent extends Component {
if (this.state.dataSource.getRowCount()) {
return (
<ListView
ref={(ref) => this.rootRef_ = ref}
dataSource={this.state.dataSource}
renderRow={(note) => {
return <NoteItem note={note}/>
@@ -89,7 +96,10 @@ class NoteListComponent extends Component {
const NoteList = connect(
(state) => {
return { items: state.notes };
return {
items: state.notes,
notesSource: state.notesSource,
};
}
)(NoteListComponent)

View File

@@ -181,11 +181,13 @@ class ScreenHeaderComponent extends Component {
function saveButton(styles, onPress, disabled, show) {
if (!show) return null;
const title = disabled ? _('Saved') : _('Save');
return (
<TouchableOpacity onPress={onPress} disabled={disabled}>
<View style={disabled ? styles.saveButtonDisabled : styles.saveButton}>
{ disabled && <Icon name='md-checkmark' style={styles.saveButtonIcon} /> }
<Text style={styles.saveButtonText}>Save</Text>
<Text style={styles.saveButtonText}>{title}</Text>
</View>
</TouchableOpacity>
);