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
1 changed files with 6 additions and 3 deletions

View File

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