From 4761606330c6d5da7120143945ce54e753f2db36 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 30 Jul 2017 23:33:54 +0200 Subject: [PATCH] Fixed list scroll position --- ReactNativeClient/lib/components/note-list.js | 12 +++++++++++- ReactNativeClient/lib/components/screen-header.js | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ReactNativeClient/lib/components/note-list.js b/ReactNativeClient/lib/components/note-list.js index 7a0d0476a0..499b347dfb 100644 --- a/ReactNativeClient/lib/components/note-list.js +++ b/ReactNativeClient/lib/components/note-list.js @@ -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 ( this.rootRef_ = ref} dataSource={this.state.dataSource} renderRow={(note) => { return @@ -89,7 +96,10 @@ class NoteListComponent extends Component { const NoteList = connect( (state) => { - return { items: state.notes }; + return { + items: state.notes, + notesSource: state.notesSource, + }; } )(NoteListComponent) diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index b056f55e66..9ca3b276f6 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -181,11 +181,13 @@ class ScreenHeaderComponent extends Component { function saveButton(styles, onPress, disabled, show) { if (!show) return null; + const title = disabled ? _('Saved') : _('Save'); + return ( { disabled && } - Save + {title} );