aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-10-17 13:57:19 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-10-17 13:57:19 +0000
commitaf3f6489d3b229da4e688eaf439adb5d3e4f070b (patch)
tree5e35aa3085580d8294db461937c88d10d3d3f078
parentcccc5a20fce4bde9a4299f8790366790735f1d05 (diff)
downloadstable-diffusion-webui-gfx803-af3f6489d3b229da4e688eaf439adb5d3e4f070b.tar.gz
stable-diffusion-webui-gfx803-af3f6489d3b229da4e688eaf439adb5d3e4f070b.tar.bz2
stable-diffusion-webui-gfx803-af3f6489d3b229da4e688eaf439adb5d3e4f070b.zip
possibly defeat losing of focus for prompt when generating images with gallery open
-rw-r--r--javascript/progressbar.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/javascript/progressbar.js b/javascript/progressbar.js
index c7d0343f..7a05726e 100644
--- a/javascript/progressbar.js
+++ b/javascript/progressbar.js
@@ -72,11 +72,17 @@ function check_gallery(id_gallery){
let galleryButtons = gradioApp().querySelectorAll('#'+id_gallery+' .gallery-item')
let galleryBtnSelected = gradioApp().querySelector('#'+id_gallery+' .gallery-item.\\!ring-2')
if (prevSelectedIndex !== -1 && galleryButtons.length>prevSelectedIndex && !galleryBtnSelected) {
- //automatically re-open previously selected index (if exists)
- activeElement = document.activeElement;
+ // automatically re-open previously selected index (if exists)
+ activeElement = gradioApp().activeElement;
+
galleryButtons[prevSelectedIndex].click();
showGalleryImage();
- if(activeElement) activeElement.focus()
+
+ if(activeElement){
+ // i fought this for about an hour; i don't know why the focus is lost or why this helps recover it
+ // if somenoe has a better solution please by all means
+ setTimeout(function() { activeElement.focus() }, 1);
+ }
}
})
galleryObservers[id_gallery].observe( gallery, { childList:true, subtree:false })