1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Desktop: Fixes #1724: Improved note selection and scrolling when moving a note to a different notebook

This commit is contained in:
Laurent Cozic 2019-07-13 17:40:09 +01:00
parent fa69957d3f
commit ca4dfe0f0f
2 changed files with 7 additions and 2 deletions

View File

@ -52,7 +52,7 @@ class ItemList extends React.Component {
makeItemIndexVisible(itemIndex) {
const top = Math.min(this.props.items.length - 1, this.state.topItemIndex + 1);
const bottom = Math.max(0, this.state.bottomItemIndex - 1)
const bottom = Math.max(0, this.state.bottomItemIndex)
if (itemIndex >= top && itemIndex <= bottom) return;

View File

@ -406,6 +406,7 @@ const reducer = (state = defaultState, action) => {
return false;
}
let movedNotePreviousIndex = 0;
let noteFolderHasChanged = false;
let newNotes = state.notes.slice();
var found = false;
@ -427,6 +428,7 @@ const reducer = (state = defaultState, action) => {
} else { // Note has moved to a different folder
newNotes.splice(i, 1);
noteFolderHasChanged = true;
movedNotePreviousIndex = i;
}
found = true;
break;
@ -447,7 +449,10 @@ const reducer = (state = defaultState, action) => {
newState.notes = newNotes;
if (noteFolderHasChanged) {
newState.selectedNoteIds = newNotes.length ? [newNotes[0].id] : [];
let newIndex = movedNotePreviousIndex;
if (newIndex >= newNotes.length) newIndex = newNotes.length - 1;
if (!newNotes.length) newIndex = -1;
newState.selectedNoteIds = newIndex >= 0 ? [newNotes[newIndex].id] : [];
}
break;