From ba5b46b570289a567197f7c915d9bce247646f1b Mon Sep 17 00:00:00 2001 From: Alex Heller Date: Sun, 4 Jun 2023 17:15:38 +0200 Subject: [PATCH] Removed repeated calls to unfold other tabs when in show all mode. --- javascript/ui.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/javascript/ui.js b/javascript/ui.js index 16d763c8c..3647864b3 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -265,15 +265,14 @@ onUiLoaded(function(){ // HACK to keep gradio from closing when showing all pages const observer = new MutationObserver(function(mutations) { const show_all_pages_dummy = gradioApp().getElementById('settings_show_all_pages') - mutations.forEach(function(mutation) { - if (mutation.type === 'attributes' && mutation.attributeName === 'style') { - if (show_all_pages_dummy.style.display != "none") { - gradioApp().querySelectorAll('#settings [id^="settings_"]').forEach(function(elem){ - elem.style.display = "block"; - }) - } - } - }) + if (show_all_pages_dummy.style.display == "none") + return; + function mutation_on_style(mut) { + return mut.type === 'attributes' && mut.attributeName === 'style' + } + if (mutations.some(mutation_on_style)) { + tab_elements.forEach((elem) => elem.style.display = "block") + } }) // Add a wrapper for the tab content (everything but the tab nav)