Commit 9cbde793 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #16118 from AUTOMATIC1111/fix-Replace-preview

fix Replace preview
parents 019df53a 957185f7
...@@ -26,6 +26,14 @@ function selected_gallery_index() { ...@@ -26,6 +26,14 @@ function selected_gallery_index() {
return all_gallery_buttons().findIndex(elem => elem.classList.contains('selected')); return all_gallery_buttons().findIndex(elem => elem.classList.contains('selected'));
} }
function gallery_container_buttons(gallery_container) {
return gradioApp().querySelectorAll(`#${gallery_container} .thumbnail-item.thumbnail-small`);
}
function selected_gallery_index_id(gallery_container) {
return Array.from(gallery_container_buttons(gallery_container)).findIndex(elem => elem.classList.contains('selected'));
}
function extract_image_from_gallery(gallery) { function extract_image_from_gallery(gallery) {
if (gallery.length == 0) { if (gallery.length == 0) {
return [null]; return [null];
......
...@@ -194,7 +194,7 @@ class UserMetadataEditor: ...@@ -194,7 +194,7 @@ class UserMetadataEditor:
def setup_ui(self, gallery): def setup_ui(self, gallery):
self.button_replace_preview.click( self.button_replace_preview.click(
fn=self.save_preview, fn=self.save_preview,
_js="function(x, y, z){return [selected_gallery_index(), y, z]}", _js=f"function(x, y, z){{return [selected_gallery_index_id('{self.tabname + '_gallery_container'}'), y, z]}}",
inputs=[self.edit_name_input, gallery, self.edit_name_input], inputs=[self.edit_name_input, gallery, self.edit_name_input],
outputs=[self.html_preview, self.html_status] outputs=[self.html_preview, self.html_status]
).then( ).then(
......
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