Skip to content

Commit bbe3f43

Browse files
committed
avoid scrolling to active node without a reason, fixes #4031
1 parent 6f16b4c commit bbe3f43

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Diff for: src/public/app/widgets/note_tree.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1002,21 +1002,21 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
10021002
this.activityDetected();
10031003

10041004
const oldActiveNode = this.getActiveNode();
1005-
let oldActiveNodeFocused = false;
10061005

1007-
if (oldActiveNode) {
1008-
oldActiveNodeFocused = oldActiveNode.hasFocus();
1009-
1010-
oldActiveNode.setActive(false);
1011-
oldActiveNode.setFocus(false);
1012-
}
1013-
1014-
if (this.noteContext
1015-
&& this.noteContext.notePath
1006+
const newActiveNode = this.noteContext?.notePath
10161007
&& !this.noteContext.note?.isDeleted
10171008
&& (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree())
1018-
) {
1019-
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
1009+
&& await this.getNodeFromPath(this.noteContext.notePath);
1010+
1011+
if (newActiveNode !== oldActiveNode) {
1012+
let oldActiveNodeFocused = false;
1013+
1014+
if (oldActiveNode) {
1015+
oldActiveNodeFocused = oldActiveNode.hasFocus();
1016+
1017+
oldActiveNode.setActive(false);
1018+
oldActiveNode.setFocus(false);
1019+
}
10201020

10211021
if (newActiveNode) {
10221022
if (!newActiveNode.isVisible()) {

0 commit comments

Comments
 (0)