From 6e3f334e1090655f581d00dd04e764fb0e3c6eeb Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Jul 2026 15:19:53 +0000 Subject: [PATCH] Reduce complexity of revealAncestors in settings search Extract isNodeHidden() and revealNode() helpers so revealAncestors drops below the cyclomatic-complexity threshold. No behavior change; verified with the headless-Chromium test. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_014gZxznuxw8L92FUMBN3Nqz --- web_interface/static/v3/js/settings-search.js | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/web_interface/static/v3/js/settings-search.js b/web_interface/static/v3/js/settings-search.js index 4b0ff04c..05401768 100644 --- a/web_interface/static/v3/js/settings-search.js +++ b/web_interface/static/v3/js/settings-search.js @@ -241,24 +241,29 @@ }); } + function isNodeHidden(node) { + return node.classList.contains('hidden') || + (node.style && node.style.display === 'none') || + window.getComputedStyle(node).display === 'none'; + } + + function revealNode(node) { + // toggleSection handles the class, inline display, and chevron. + if (node.id && typeof window.toggleSection === 'function') { + window.toggleSection(node.id); + } else { + node.classList.remove('hidden'); + node.style.display = 'block'; + } + } + // Reveal any collapsed nested section (from render_nested_section) so the // target field is actually visible before we scroll to it. function revealAncestors(el) { var node = el.parentElement; while (node && node !== document.body) { - if (node.classList && node.classList.contains('nested-content')) { - var hidden = node.classList.contains('hidden') || - (node.style && node.style.display === 'none') || - (window.getComputedStyle(node).display === 'none'); - if (hidden) { - // toggleSection handles the class, inline display, and chevron. - if (node.id && typeof window.toggleSection === 'function') { - window.toggleSection(node.id); - } else { - node.classList.remove('hidden'); - node.style.display = 'block'; - } - } + if (node.classList && node.classList.contains('nested-content') && isNodeHidden(node)) { + revealNode(node); } node = node.parentElement; }