fix focusing title after creating a note

This commit is contained in:
zadam 2020-06-04 21:44:34 +02:00
parent 1502b9ce66
commit 58fa0832f6
4 changed files with 13 additions and 11 deletions

View File

@ -34,7 +34,7 @@ export default class MainTreeExecutors extends Component {
return;
}
const {note} = await noteCreateService.createNote(activeNote.noteId, {
await noteCreateService.createNote(activeNote.noteId, {
isProtected: activeNote.isProtected,
saveSelection: false
});
@ -56,4 +56,4 @@ export default class MainTreeExecutors extends Component {
saveSelection: false
});
}
}
}

View File

@ -73,7 +73,7 @@ class TabContext extends Component {
protectedSessionHolder.touchProtectedSessionIfNecessary(this.note);
if (triggerSwitchEvent) {
this.triggerEvent('tabNoteSwitched', {
await this.triggerEvent('tabNoteSwitched', {
tabContext: this,
notePath: this.notePath
});
@ -127,4 +127,4 @@ class TabContext extends Component {
}
}
export default TabContext;
export default TabContext;

View File

@ -203,7 +203,7 @@ export default class TabManager extends Component {
if (activate) {
this.activateTab(tabContext.tabId, false);
this.triggerEvent('tabNoteSwitchedAndActivated', {
await this.triggerEvent('tabNoteSwitchedAndActivated', {
tabContext,
notePath: tabContext.notePath // resolved note path
});

View File

@ -854,8 +854,11 @@ export default class NoteTreeWidget extends TabAwareWidget {
this.toggleInt(this.isEnabled());
const oldActiveNode = this.getActiveNode();
let oldActiveNodeFocused = false;
if (oldActiveNode) {
oldActiveNodeFocused = oldActiveNode.hasFocus();
oldActiveNode.setActive(false);
oldActiveNode.setFocus(false);
}
@ -868,8 +871,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
await this.expandToNote(this.tabContext.notePath);
}
newActiveNode.setActive(true, {noEvents: true});
newActiveNode.setActive(true, {noEvents: true, noFocus: !oldActiveNodeFocused});
newActiveNode.makeVisible({scrollIntoView: true});
}
}
@ -898,7 +900,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
async entitiesReloadedEvent({loadResults}) {
const activeNode = this.getActiveNode();
const activeNodeFocused = activeNode ? activeNode.hasFocus() : false;
const activeNodeFocused = activeNode && activeNode.hasFocus();
const nextNode = activeNode ? (activeNode.getNextSibling() || activeNode.getPrevSibling() || activeNode.getParent()) : null;
const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;
@ -1021,7 +1023,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
}
if (node) {
node.setActive(true, {noEvents: true});
node.setActive(true, {noEvents: true, noFocus: true});
}
else {
// this is used when original note has been deleted and we want to move the focus to the note above/below
@ -1036,7 +1038,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
// return focus if the previously active node was also focused
if (newActiveNode && activeNodeFocused) {
newActiveNode.setFocus(true);
await newActiveNode.setFocus(true);
}
}
}
@ -1064,7 +1066,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
if (activeNotePath) {
const node = await this.getNodeFromPath(activeNotePath, true);
await node.setActive(true, {noEvents: true});
await node.setActive(true, {noEvents: true, noFocus: true});
}
}