diff --git a/graphify/export.py b/graphify/export.py index 2870fdcc0..7bb54670e 100644 --- a/graphify/export.py +++ b/graphify/export.py @@ -183,9 +183,28 @@ def _html_script(nodes_json: str, edges_json: str, legend_json: str) -> str: showInfo(nodeId); }} +// Track hovered node — hover detection is more reliable than click params +let hoveredNodeId = null; +network.on('hoverNode', params => {{ + hoveredNodeId = params.node; + container.style.cursor = 'pointer'; +}}); +network.on('blurNode', () => {{ + hoveredNodeId = null; + container.style.cursor = 'default'; +}}); +container.addEventListener('click', () => {{ + if (hoveredNodeId !== null) {{ + showInfo(hoveredNodeId); + network.selectNodes([hoveredNodeId]); + }} +}}); network.on('click', params => {{ - if (params.nodes.length > 0) showInfo(params.nodes[0]); - else document.getElementById('info-content').innerHTML = 'Click a node to inspect it'; + if (params.nodes.length > 0) {{ + showInfo(params.nodes[0]); + }} else if (hoveredNodeId === null) {{ + document.getElementById('info-content').innerHTML = 'Click a node to inspect it'; + }} }}); const searchInput = document.getElementById('search'); diff --git a/tests/visual_test_click.py b/tests/visual_test_click.py new file mode 100644 index 000000000..33b11ada3 --- /dev/null +++ b/tests/visual_test_click.py @@ -0,0 +1,287 @@ +#!/usr/bin/env python3 +"""Visual browser test for node click detection. + +Generates an HTML file with a rich mixed graph (code, document, paper, image, +rationale nodes — mirroring both tree-sitter and LLM extraction paths) and +opens it in the default browser. A debug overlay shows real-time event feedback. + +Manual verification steps: + 1. Hover over a node -> overlay shows "HOVER: