keep focus on current element when updating gallery
This commit is contained in:
parent
fc220a51cf
commit
c57919ea2a
@ -34,7 +34,7 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip
|
|||||||
preview.style.height = gallery.clientHeight + "px"
|
preview.style.height = gallery.clientHeight + "px"
|
||||||
|
|
||||||
//only watch gallery if there is a generation process going on
|
//only watch gallery if there is a generation process going on
|
||||||
check_gallery(id_gallery);
|
check_gallery(id_gallery);
|
||||||
|
|
||||||
var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0;
|
var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0;
|
||||||
if(!progressDiv){
|
if(!progressDiv){
|
||||||
@ -73,8 +73,10 @@ function check_gallery(id_gallery){
|
|||||||
let galleryBtnSelected = gradioApp().querySelector('#'+id_gallery+' .gallery-item.\\!ring-2')
|
let galleryBtnSelected = gradioApp().querySelector('#'+id_gallery+' .gallery-item.\\!ring-2')
|
||||||
if (prevSelectedIndex !== -1 && galleryButtons.length>prevSelectedIndex && !galleryBtnSelected) {
|
if (prevSelectedIndex !== -1 && galleryButtons.length>prevSelectedIndex && !galleryBtnSelected) {
|
||||||
//automatically re-open previously selected index (if exists)
|
//automatically re-open previously selected index (if exists)
|
||||||
|
activeElement = document.activeElement;
|
||||||
galleryButtons[prevSelectedIndex].click();
|
galleryButtons[prevSelectedIndex].click();
|
||||||
showGalleryImage();
|
showGalleryImage();
|
||||||
|
if(activeElement) activeElement.focus()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
galleryObservers[id_gallery].observe( gallery, { childList:true, subtree:false })
|
galleryObservers[id_gallery].observe( gallery, { childList:true, subtree:false })
|
||||||
|
Loading…
Reference in New Issue
Block a user