From 995f31103eb06e62c9c7d0f3440e6ff0a19d8330 Mon Sep 17 00:00:00 2001 From: LPeter1997 Date: Fri, 22 Sep 2023 15:45:40 +0200 Subject: [PATCH] Update TimelineGraph.tsx --- src/Draco.Trace.Visualizer/src/TimelineGraph.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Draco.Trace.Visualizer/src/TimelineGraph.tsx b/src/Draco.Trace.Visualizer/src/TimelineGraph.tsx index 8c19ec52e..1127ff3ff 100644 --- a/src/Draco.Trace.Visualizer/src/TimelineGraph.tsx +++ b/src/Draco.Trace.Visualizer/src/TimelineGraph.tsx @@ -1,7 +1,7 @@ import * as d3 from "d3"; import React from "react"; import { MessageModel, ThreadModel, TraceModel } from "./Model"; -import { TimelineLayoutSettings, focusVisualsOnNode, layoutTimeline } from "./graph_utils"; +import { HierarchicalBarGraphNode, TimelineLayoutSettings, focusVisualsOnNode, layoutTimeline } from "./graph_utils"; type Props = { width: number; @@ -103,8 +103,17 @@ function buildGraph(domRef: React.MutableRefObject, props: Props) { svg.call(zoom as any); + let lastFocused: HierarchicalBarGraphNode | undefined = undefined; allRects.on('click', function (element, node) { - focusVisualsOnNode(node); + if (lastFocused === node) { + // Focus on root + focusVisualsOnNode(laidOutMessages.root); + lastFocused = undefined; + } + else { + focusVisualsOnNode(node); + lastFocused = node; + } const transition = d3 .transition()