Fix left/right arrow expand/collapse logic

Now checks actual DOM state instead of collapsedNodes set,
which fixes behavior with depth-based auto-collapse.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-02 22:05:43 -05:00
parent c15b69e3e7
commit a132b3634e
@@ -762,7 +762,9 @@ document.addEventListener('keydown', (e) => {
e.preventDefault();
if (selectedIndex >= 0 && selectedIndex < visibleNodes.length) {
const id = visibleNodes[selectedIndex].dataset.id;
if (collapsedNodes.has(id)) {
const childContainer = document.querySelector(`.children-container[data-parent="${id}"]`);
// Expand if currently collapsed
if (childContainer && childContainer.classList.contains('collapsed')) {
toggleNode(id);
}
}
@@ -773,14 +775,10 @@ document.addEventListener('keydown', (e) => {
e.preventDefault();
if (selectedIndex >= 0 && selectedIndex < visibleNodes.length) {
const id = visibleNodes[selectedIndex].dataset.id;
if (!collapsedNodes.has(id)) {
const person = familyTreeData[id];
const hasExpandable = currentRoot === 'jesus'
? (person.parents && person.parents.length > 0)
: (person.children && person.children.length > 0);
if (hasExpandable) {
toggleNode(id);
}
const childContainer = document.querySelector(`.children-container[data-parent="${id}"]`);
// Collapse if currently expanded
if (childContainer && !childContainer.classList.contains('collapsed')) {
toggleNode(id);
}
}
break;