From c57919ea2a8e4a23a05d21f28928e08bbf34c59e Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 16 Oct 2022 17:22:56 +0300 Subject: [PATCH] keep focus on current element when updating gallery --- javascript/progressbar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 076f0a97..c7d0343f 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -34,7 +34,7 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip preview.style.height = gallery.clientHeight + "px" //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; if(!progressDiv){ @@ -73,8 +73,10 @@ function check_gallery(id_gallery){ 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; galleryButtons[prevSelectedIndex].click(); - showGalleryImage(); + showGalleryImage(); + if(activeElement) activeElement.focus() } }) galleryObservers[id_gallery].observe( gallery, { childList:true, subtree:false })