mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Focus on the rename text area when it becomes visible
This commit is contained in:
parent
6e9d814095
commit
4d730a759a
28
js/main.js
28
js/main.js
@ -397,3 +397,31 @@ function updateDocumentWidth() {
|
||||
|
||||
updateDocumentWidth();
|
||||
window.addEventListener("resize", updateDocumentWidth);
|
||||
|
||||
//------------------------------------------------
|
||||
// Focus on the rename text area when it becomes visible
|
||||
//------------------------------------------------
|
||||
const renameTextArea = document.getElementById('rename-row').querySelector('textarea');
|
||||
|
||||
function respondToVisibility(element, callback) {
|
||||
var options = {
|
||||
root: document.documentElement,
|
||||
};
|
||||
|
||||
var observer = new IntersectionObserver((entries, observer) => {
|
||||
entries.forEach(entry => {
|
||||
callback(entry.intersectionRatio > 0);
|
||||
});
|
||||
}, options);
|
||||
|
||||
observer.observe(element);
|
||||
}
|
||||
|
||||
|
||||
function handleVisibilityChange(isVisible) {
|
||||
if (isVisible) {
|
||||
renameTextArea.focus();
|
||||
}
|
||||
}
|
||||
|
||||
respondToVisibility(renameTextArea, handleVisibilityChange);
|
||||
|
Loading…
Reference in New Issue
Block a user