From ee1cd684a816166743fc946a27aa0096c7d5b190 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 10 Jul 2026 12:03:58 -0500 Subject: [PATCH] Debug: detectar contenedor anidado cuando doc-body no tiene esquema-sep como hijo directo Co-Authored-By: Claude Sonnet 4.6 --- ver_formulario_enviado.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index 3a681a9..2ae8372 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -1320,12 +1320,30 @@ function _mpApplyExamVisibility(selectedExam) { // (no querySelectorAll — así capturamos section-title y otros sin data-campo-id) var docBody = document.querySelector('.doc-body'); if (!docBody) { console.warn('[tomas] .doc-body no encontrado'); return; } + // Encontrar el contenedor real donde están los campos + var fieldContainer = docBody; var children = Array.from(docBody.children); - console.log('[tomas] docBody.children.length:', children.length, - '| seps en children:', children.filter(function(c){return c.classList.contains('esquema-sep');}).length); + var sepsInChildren = children.filter(function(c){return c.classList.contains('esquema-sep');}).length; + console.log('[tomas] docBody.children.length:', children.length, '| seps en children:', sepsInChildren); + if (sepsInChildren === 0 && children.length > 0) { + // Los campos están anidados — buscar el contenedor que tenga esquema-sep + var found = null; + children.forEach(function(child) { + if (!found && child.querySelector('.esquema-sep')) found = child; + }); + if (found) { + fieldContainer = found; + console.log('[tomas] usando contenedor anidado:', found.tagName, found.className); + } else { + // Intentar con querySelectorAll en todo el doc-body + console.warn('[tomas] no se encontró .esquema-sep en hijos directos, usando querySelectorAll fallback'); + fieldContainer = null; + } + } + var childList = fieldContainer ? Array.from(fieldContainer.children) : []; var inHidden = false; var hiddenCount = 0; - children.forEach(function(child) { + childList.forEach(function(child) { if (child.classList.contains('esquema-sep')) { var cid = child.getAttribute('data-campo-id') || ''; if (allTomaSeps[cid] !== undefined) {