From 4f5868366a0e7232aa2f4163757f4a501ecd55a5 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 2 Dec 2025 20:37:46 -0500 Subject: [PATCH] Fix expand button click in interactive family tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The renderTreeFromId click handler was missing the expand indicator logic, so clicking the "+" button didn't work. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../templates/family_tree_interactive.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kjvstudy_org/templates/family_tree_interactive.html b/kjvstudy_org/templates/family_tree_interactive.html index 942fc96..3b417d6 100644 --- a/kjvstudy_org/templates/family_tree_interactive.html +++ b/kjvstudy_org/templates/family_tree_interactive.html @@ -1779,7 +1779,7 @@ function renderTreeFromId(personId, animate = true) { this.appendChild(card); }); - // Single click: handle info button + // Single click: handle info button and expand nodes.on('click', (event, d) => { event.stopPropagation(); @@ -1791,8 +1791,21 @@ function renderTreeFromId(personId, animate = true) { if (isInfoClick) { showPersonInfo(d.data); + return; + } + + // Check if clicking on the expand indicator + const isExpandClick = target.classList.contains('expand-indicator') || + target.classList.contains('expand-icon'); + + // Check if node can be expanded/collapsed + const hasHiddenChildren = d._children && d._children.length > 0; + const hasExpandableChildren = d.data.data && d.data.data.hasChildren && !d.children && !d._children; + const canExpand = hasHiddenChildren || hasExpandableChildren; + + if (isExpandClick && canExpand) { + toggleNode(d); } - // Clicking elsewhere does nothing (use info button or double-click) }); // Double click: re-center