From 87f11bcd2ba95047cae6ce0f03db841f25bf166d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 30 Nov 2025 00:29:24 -0500 Subject: [PATCH] TOC entry Enter jumps to section content instead of anchor navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When pressing Enter on a TOC entry, now selects the first content element (title/paragraph) in that section for keyboard navigation instead of just scrolling to the anchor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- kjvstudy_org/templates/resource_index.html | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/kjvstudy_org/templates/resource_index.html b/kjvstudy_org/templates/resource_index.html index 739ea49..201db53 100644 --- a/kjvstudy_org/templates/resource_index.html +++ b/kjvstudy_org/templates/resource_index.html @@ -416,9 +416,28 @@ document.addEventListener('DOMContentLoaded', function() { // Drill into TOC items selectTocItem(0); } else if (currentSection === 'toc' && selectedTocIndex >= 0) { - // Navigate to the linked section + // Jump to first content element in that section var href = tocItems[selectedTocIndex].getAttribute('href'); - if (href) window.location.href = href; + if (href) { + var targetId = href.substring(1); // Remove the # + var targetHeading = document.getElementById(targetId); + if (targetHeading) { + // Find the resource-name within or near this heading's section + var section = targetHeading.closest('.resource-entry') || targetHeading.closest('.resource-section'); + if (section) { + var firstElement = section.querySelector('.resource-name, .resource-item-description p, .verse-item'); + if (firstElement) { + var idx = contentElements.indexOf(firstElement); + if (idx >= 0) { + selectContentElement(idx); + return; + } + } + } + } + // Fallback: scroll to the anchor + window.location.href = href; + } } else if (selectedIndex >= 0) { var el = contentElements[selectedIndex]; // Check if the element itself contains a link, or is an h3 with a link inside