Skip to content

Commit

Permalink
Merge pull request #16118 from AUTOMATIC1111/fix-Replace-preview
Browse files Browse the repository at this point in the history
fix Replace preview
  • Loading branch information
AUTOMATIC1111 committed Jul 6, 2024
2 parents 019df53 + 957185f commit 9cbde79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions javascript/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ function selected_gallery_index() {
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) {
if (gallery.length == 0) {
return [null];
Expand Down
2 changes: 1 addition & 1 deletion modules/ui_extra_networks_user_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def save_preview(self, index, gallery, name):
def setup_ui(self, gallery):
self.button_replace_preview.click(
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],
outputs=[self.html_preview, self.html_status]
).then(
Expand Down

0 comments on commit 9cbde79

Please sign in to comment.