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:
parent
fa69957d3f
commit
ca4dfe0f0f
@ -52,7 +52,7 @@ class ItemList extends React.Component {
|
|||||||
|
|
||||||
makeItemIndexVisible(itemIndex) {
|
makeItemIndexVisible(itemIndex) {
|
||||||
const top = Math.min(this.props.items.length - 1, this.state.topItemIndex + 1);
|
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;
|
if (itemIndex >= top && itemIndex <= bottom) return;
|
||||||
|
|
||||||
|
@ -406,6 +406,7 @@ const reducer = (state = defaultState, action) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let movedNotePreviousIndex = 0;
|
||||||
let noteFolderHasChanged = false;
|
let noteFolderHasChanged = false;
|
||||||
let newNotes = state.notes.slice();
|
let newNotes = state.notes.slice();
|
||||||
var found = false;
|
var found = false;
|
||||||
@ -427,6 +428,7 @@ const reducer = (state = defaultState, action) => {
|
|||||||
} else { // Note has moved to a different folder
|
} else { // Note has moved to a different folder
|
||||||
newNotes.splice(i, 1);
|
newNotes.splice(i, 1);
|
||||||
noteFolderHasChanged = true;
|
noteFolderHasChanged = true;
|
||||||
|
movedNotePreviousIndex = i;
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -447,7 +449,10 @@ const reducer = (state = defaultState, action) => {
|
|||||||
newState.notes = newNotes;
|
newState.notes = newNotes;
|
||||||
|
|
||||||
if (noteFolderHasChanged) {
|
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;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user