mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 06:45:49 +01:00
keep focus when clicking on edit read only note
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user