Commit c57919ea authored by AUTOMATIC's avatar AUTOMATIC

keep focus on current element when updating gallery

parent fc220a51
...@@ -73,8 +73,10 @@ function check_gallery(id_gallery){ ...@@ -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 })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment