Skip to content

Commit 35c49b7

Browse files
committed
Fix trace fullscreen highlighting (#971)
* fix scroll * fix highlighting
1 parent eda633d commit 35c49b7

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

assets/app/hooks/trace_body_search_highlight.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
import { highlightSearchRanges } from '../utils/dom';
1+
import { highlightSearchRanges, findRanges } from '../utils/dom';
22

3-
import { findRanges } from '../utils/dom';
3+
const rangesByElementId = new Map();
4+
5+
function updateGlobalHighlight() {
6+
const allRanges = Array.from(rangesByElementId.values()).flat();
7+
highlightSearchRanges('traces-search-highlight', allRanges, true);
8+
}
49

510
const TraceBodySearchHighlight = {
611
mounted() {
7-
const phrase = this.el.dataset.search_phrase;
8-
if (phrase === undefined || phrase === '') return;
9-
10-
const ranges = findRanges(this.el, phrase);
11-
highlightSearchRanges('traces-search-highlight', ranges);
12+
this.handleHighlight();
1213
},
14+
1315
updated() {
16+
this.handleHighlight();
17+
},
18+
19+
destroyed() {
20+
rangesByElementId.delete(this.el.id);
21+
updateGlobalHighlight();
22+
},
23+
24+
handleHighlight() {
1425
const phrase = this.el.dataset.search_phrase;
15-
if (phrase === undefined || phrase === '') return;
1626

17-
const ranges = findRanges(this.el, phrase);
18-
highlightSearchRanges('traces-search-highlight', ranges);
27+
if (!phrase) {
28+
rangesByElementId.delete(this.el.id);
29+
} else {
30+
rangesByElementId.set(this.el.id, findRanges(this.el, phrase));
31+
}
32+
33+
updateGlobalHighlight();
1934
},
2035
};
2136

lib/live_debugger/app/debugger/callback_tracing/web/components/trace.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ defmodule LiveDebugger.App.Debugger.CallbackTracing.Web.Components.Trace do
336336
/>
337337
</div>
338338
<div class={[
339-
"max-h-[70vh] overflow-y-auto overflow-x-auto flex flex-col gap-4 items-start justify-center hover:[&>div>div>div>button]:hidden",
339+
"max-h-[70vh] overflow-y-auto overflow-x-auto flex flex-col gap-4 items-start justify-start hover:[&>div>div>div>button]:hidden",
340340
if(is_nil(@displayed_trace.error), do: "p-4", else: "[&>div>div>div>div>button]:hidden")
341341
]}>
342342
<.trace_body_navbar_wrapper

0 commit comments

Comments
 (0)