change condition for scheduleAfterScriptsCallbacks() to properly reflect the needed amount of search fields

This commit is contained in:
AUTOMATIC1111 2024-02-17 09:45:03 +03:00
parent f293dbbf97
commit 2e1b61e590

View File

@ -622,10 +622,13 @@ function scheduleAfterScriptsCallbacks() {
}, 200); }, 200);
} }
document.addEventListener("DOMContentLoaded", function() { onUiLoaded(function() {
var mutationObserver = new MutationObserver(function(m) { var mutationObserver = new MutationObserver(function(m) {
if (!executedAfterScripts && let existingSearchfields = gradioApp().querySelectorAll("[id$='_extra_search']").length;
gradioApp().querySelectorAll("[id$='_extra_search']").length >= 6) { let neededSearchfields = gradioApp().querySelectorAll("[id$='_extra_tabs'] > .tab-nav > button").length - 2;
if (!executedAfterScripts && existingSearchfields >= neededSearchfields) {
mutationObserver.disconnect();
executedAfterScripts = true; executedAfterScripts = true;
scheduleAfterScriptsCallbacks(); scheduleAfterScriptsCallbacks();
} }