From 84df9f7b4df30b08b8a315afe4c4ce9d8f91436d Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sat, 23 Aug 2025 03:53:43 +0100 Subject: [PATCH] extraNetworks.js fix for networks menu with process caption gallery tabs More robust code by adding a simple check to ensure that searchTextarea is not null, added a check for debugging if it ever fails again Fixed getENActiveTab, expression tabName in ['process', 'caption', 'gallery'] will always solve as false, making network menus inoperable when in either of these tabs. --- javascript/extraNetworks.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index e13323307..81d11d684 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -14,7 +14,7 @@ const getENActiveTab = () => { else if (gradioApp().getElementById('extras_image')?.checkVisibility()) tabName = 'process'; else if (gradioApp().getElementById('interrogate_image')?.checkVisibility()) tabName = 'caption'; else if (gradioApp().getElementById('tab-gallery-search')?.checkVisibility()) tabName = 'gallery'; - if (tabName in ['process', 'caption', 'gallery']) tabName = lastTab; + if (['process', 'caption', 'gallery'].includes(tabName)) tabName = lastTab; else lastTab = tabName; if (tabName !== '') return tabName; // legacy method @@ -277,8 +277,12 @@ function extraNetworksSearchButton(event) { const tabName = getENActiveTab(); const searchTextarea = gradioApp().querySelector(`#${tabName}_extra_search textarea`); const button = event.target; - searchTextarea.value = `${button.textContent.trim()}/`; - updateInput(searchTextarea); + if (searchTextarea) { + searchTextarea.value = `${button.textContent.trim()}/`; + updateInput(searchTextarea); + } else { + console.error(`Could not find the search textarea for the tab: ${tabName}`); + } } let desiredStyle = '';