diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index 4e30261b8..1610698bf 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -454,16 +454,18 @@ function extraNetworksControlTreeViewOnClick(event, tabname, extra_networks_tabn if (tree.classList.contains("hidden")) { tree.style.display = 'none'; - resizeHandle.style.display = 'none'; parent.style.display = 'flex'; + if (resizeHandle) { + resizeHandle.style.display = 'none'; + } } else { tree.style.display = 'block'; + parent.style.display = 'grid'; if (!resizeHandle) { setupResizeHandle(parent); resizeHandle = parent.querySelector('.resize-handle'); } resizeHandle.style.display = 'block'; - parent.style.display = 'grid'; } event.currentTarget.classList.toggle("extra-network-control--enabled"); } diff --git a/javascript/resizeHandle.js b/javascript/resizeHandle.js index cf2c778bb..94ae4aaa2 100644 --- a/javascript/resizeHandle.js +++ b/javascript/resizeHandle.js @@ -166,18 +166,15 @@ setupResizeHandle = setup; })(); -onUiLoaded(function() { - for (var elem of gradioApp().querySelectorAll('.resize-handle-row')) { - if (!elem.querySelector('.resize-handle')) { - setupResizeHandle(elem); - } - } -}); -function setupExtraNetworksResizeHandle() { - for (var elem of document.body.querySelectorAll('.resize-handle-row')) { +function setupAllResizeHandles() { + for (var elem of gradioApp().querySelectorAll('.resize-handle-row')) { if (!elem.querySelector('.resize-handle') && !elem.children[0].classList.contains("hidden")) { setupResizeHandle(elem); } } } + + +onUiLoaded(setupAllResizeHandles); + diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index 09705a98c..9d8f8b28b 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -700,7 +700,7 @@ def create_ui(interface: gr.Blocks, unrelated_tabs, tabname): return ui.pages_contents button_refresh = gr.Button("Refresh", elem_id=f"{tabname}_{page.extra_networks_tabname}_extra_refresh_internal", visible=False) - button_refresh.click(fn=refresh, inputs=[], outputs=ui.pages).then(fn=lambda: None, _js="function(){ " + f"applyExtraNetworkFilter('{tabname}_{page.extra_networks_tabname}');" + " }") + button_refresh.click(fn=refresh, inputs=[], outputs=ui.pages).then(fn=lambda: None, _js="function(){ " + f"applyExtraNetworkFilter('{tabname}_{page.extra_networks_tabname}');" + " }").then(fn=lambda: None, _js='setupAllResizeHandles') def create_html(): ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages] @@ -710,7 +710,7 @@ def create_ui(interface: gr.Blocks, unrelated_tabs, tabname): create_html() return ui.pages_contents - interface.load(fn=pages_html, inputs=[], outputs=ui.pages).then(fn=lambda: None, _js='setupExtraNetworksResizeHandle') + interface.load(fn=pages_html, inputs=[], outputs=ui.pages).then(fn=lambda: None, _js='setupAllResizeHandles') return ui