diff --git a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx index f65b8d6..2e70f14 100644 --- a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx +++ b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx @@ -116,6 +116,8 @@ export function EpiphanyGraphViewer({ }); const dragRef = useRef(null); const explicitFocusRef = useRef(null); + const pendingSelectionFocusRef = useRef(null); + const lastSelectionKeyRef = useRef(null); const selection = controlledSelection === undefined ? localSelection : controlledSelection; const layoutModeKey = layoutModeCacheKey(layoutMode); const motionOptions = resolveMotionOptions(layoutMode, motion); @@ -299,7 +301,7 @@ export function EpiphanyGraphViewer({ } const onWheel = (event: WheelEvent) => { - if (isArticleContentTarget(event.target)) { + if (!event.altKey && isArticleContentTarget(event.target)) { return; } @@ -379,6 +381,28 @@ export function EpiphanyGraphViewer({ expandedNode?.graphKey === activeGraphKey && expandedNode.nodeId === selectedNode?.id; + useEffect(() => { + const selectionKey = + selection?.kind === "node" && selection.graphKey === activeGraphKey + ? `${activeGraphKey}:${selection.nodeId}` + : null; + + if (selectionKey && selectionKey !== lastSelectionKeyRef.current) { + if (explicitFocusRef.current !== selectionKey) { + pendingSelectionFocusRef.current = selectionKey; + } + lastSelectionKeyRef.current = selectionKey; + } else if (!selectionKey) { + lastSelectionKeyRef.current = null; + pendingSelectionFocusRef.current = null; + } + }, [ + activeGraphKey, + selection?.kind, + selection?.graphKey, + selection?.kind === "node" ? selection.nodeId : null, + ]); + useEffect(() => { if (!activeLayout || !activeTransform.userMoved || viewportSize.width <= 0 || viewportSize.height <= 0) { return; @@ -386,10 +410,15 @@ export function EpiphanyGraphViewer({ const centeredNode = nodeNearestViewportCenter(activeLayout.nodes, activeTransform, viewportSize.width, viewportSize.height); const selectedNodeId = selection?.kind === "node" && selection.graphKey === activeGraphKey ? selection.nodeId : null; + const selectedNodeKey = selectedNodeId ? `${activeGraphKey}:${selectedNodeId}` : null; if (!centeredNode || selectedNodeId === centeredNode.id) { return; } + if (selectedNodeKey && pendingSelectionFocusRef.current === selectedNodeKey) { + return; + } + explicitFocusRef.current = `${activeGraphKey}:${centeredNode.id}`; updateSelection({ kind: "node", @@ -418,9 +447,11 @@ export function EpiphanyGraphViewer({ const selectionKey = `${activeGraphKey}:${selectedNode.id}`; if (explicitFocusRef.current === selectionKey) { explicitFocusRef.current = null; + pendingSelectionFocusRef.current = null; return; } + pendingSelectionFocusRef.current = null; focusNodeInViewport( selectedNode, activeGraphKey, @@ -561,6 +592,11 @@ export function EpiphanyGraphViewer({
{ + if (isMiddlePointerEvent(event) || (event.altKey && event.button === 0)) { + handleViewportPointerDown(event, activeTransform, dragRef); + return; + } + if ( (event.button !== 0 && !isMiddlePointerEvent(event)) || isInteractiveArticleTarget(event.target) || @@ -764,6 +800,10 @@ export function EpiphanyGraphViewer({ aria-label={nodeArticleSurface?.ariaLabel ?? node.title} className={className} onClickCapture={(event) => { + if (event.altKey) { + return; + } + if (!rendersArticle) { return; } @@ -778,7 +818,9 @@ export function EpiphanyGraphViewer({ onExpandedNodeClick?.(event); }} onPointerDown={(event) => { - event.stopPropagation(); + if (!event.altKey) { + event.stopPropagation(); + } }} onClick={(event) => { if (dragRef.current?.suppressClick) { @@ -2517,7 +2559,7 @@ function isArticleContentTarget(target: EventTarget | null) { } const articleDetail = Number(surface.style.getPropertyValue("--node-article")); - return Number.isFinite(articleDetail) && articleDetail > 0.18; + return Number.isFinite(articleDetail) && articleDetail >= 0.92; } function nudgeZoom(