keep focus when clicking on edit read only note

This commit is contained in:
zadam
2021-06-24 23:50:56 +02:00
parent f1a36f6cea
commit 1b9c3b0759
8 changed files with 99 additions and 83 deletions

View File

@@ -7,10 +7,38 @@ export default class ScrollingContainer extends Container {
this.css('overflow', 'auto');
}
setNoteContextEvent({noteContext}) {
/** @var {NoteContext} */
this.noteContext = noteContext;
}
async noteSwitchedEvent({noteContext, notePath}) {
// if notePath does not match then the noteContext has been switched to another note in the mean time
if (noteContext.notePath === notePath) {
this.$widget.scrollTop(0);
this.$widget.scrollTop(0);
}
async noteSwitchedAndActivatedEvent({noteContext, notePath}) {
this.noteContext = noteContext;
this.$widget.scrollTop(0);
}
async activeContextChangedEvent({noteContext}) {
this.noteContext = noteContext;
}
handleEventInChildren(name, data) {
if (name === 'readOnlyTemporarilyDisabled'
&& this.noteContext
&& this.noteContext.ntxId === data.noteContext.ntxId) {
const scrollTop = this.$widget.scrollTop();
const promise = super.handleEventInChildren(name, data);
promise.then(() => setTimeout(() => this.$widget.scrollTop(scrollTop), 500));
}
else {
return super.handleEventInChildren(name, data);
}
}
}