mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-18 04:37:22 +02:00
Preserve scroll position of the prompt manager
This commit is contained in:
parent
d69263923a
commit
9c3176b29f
@ -685,6 +685,23 @@ class PromptManager {
|
|||||||
this.log('Initialized');
|
this.log('Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scroll position of the prompt manager
|
||||||
|
* @returns {number} - Scroll position of the prompt manager
|
||||||
|
*/
|
||||||
|
#getScrollPosition() {
|
||||||
|
return document.getElementById(this.configuration.prefix + 'prompt_manager')?.closest('.scrollableInner')?.scrollTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scroll position of the prompt manager
|
||||||
|
* @param {number} scrollPosition - The scroll position to set
|
||||||
|
*/
|
||||||
|
#setScrollPosition(scrollPosition) {
|
||||||
|
if (scrollPosition === undefined || scrollPosition === null) return;
|
||||||
|
document.getElementById(this.configuration.prefix + 'prompt_manager')?.closest('.scrollableInner')?.scrollTo(0, scrollPosition);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main rendering function
|
* Main rendering function
|
||||||
*
|
*
|
||||||
@ -703,17 +720,21 @@ class PromptManager {
|
|||||||
this.tryGenerate().finally(async () => {
|
this.tryGenerate().finally(async () => {
|
||||||
this.profileEnd('filling context');
|
this.profileEnd('filling context');
|
||||||
this.profileStart('render');
|
this.profileStart('render');
|
||||||
|
const scrollPosition = this.#getScrollPosition();
|
||||||
await this.renderPromptManager();
|
await this.renderPromptManager();
|
||||||
await this.renderPromptManagerListItems();
|
await this.renderPromptManagerListItems();
|
||||||
this.makeDraggable();
|
this.makeDraggable();
|
||||||
|
this.#setScrollPosition(scrollPosition);
|
||||||
this.profileEnd('render');
|
this.profileEnd('render');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Executed during live communication
|
// Executed during live communication
|
||||||
this.profileStart('render');
|
this.profileStart('render');
|
||||||
|
const scrollPosition = this.#getScrollPosition();
|
||||||
await this.renderPromptManager();
|
await this.renderPromptManager();
|
||||||
await this.renderPromptManagerListItems();
|
await this.renderPromptManagerListItems();
|
||||||
this.makeDraggable();
|
this.makeDraggable();
|
||||||
|
this.#setScrollPosition(scrollPosition);
|
||||||
this.profileEnd('render');
|
this.profileEnd('render');
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user