Skip to content

Commit

Permalink
possibly defeat losing of focus for prompt when generating images wit…
Browse files Browse the repository at this point in the history
…h gallery open
  • Loading branch information
AUTOMATIC1111 committed Oct 17, 2022
1 parent cccc5a2 commit af3f648
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions javascript/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit af3f648

Please sign in to comment.