Skip to content

Commit b5dc58f

Browse files
committed
fix: resolve database view find count and navigation regressions
Prevent non-visible views from dispatching lv-find-results which overwrote the active view's match count in FindWidget. Fall back to the raw field value in headless formatter when custom elements like <call-stack> yield empty textContent in a detached element. Remove lv-find-match from DMLView/SOQLView since DatabaseView orchestrates match navigation via highlightIndex property binding. Fix SOQLView dispatching db-find-results with type 'dml' instead of 'soql'. Add disconnectedCallback to DatabaseView for listener cleanup.
1 parent 753e651 commit b5dc58f

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

log-viewer/src/features/analysis/components/AnalysisView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ export class AnalysisView extends LitElement {
247247
this.totalMatches = result.totalMatches;
248248
this.findMap = result.matchIndexes;
249249

250-
if (!clearHighlights) {
250+
if (!clearHighlights && isTableVisible) {
251251
document.dispatchEvent(
252252
new CustomEvent('lv-find-results', { detail: { totalMatches: result.totalMatches } }),
253253
);
254254
}
255255
}
256256

257-
if (this.totalMatches <= 0) {
257+
if (this.totalMatches <= 0 || !isTableVisible) {
258258
return;
259259
}
260260
this.blockClearHighlights = true;

log-viewer/src/features/call-tree/components/CalltreeView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,15 @@ export class CalltreeView extends LitElement {
395395
this.totalMatches = result.totalMatches;
396396
this.findMap = result.matchIndexes;
397397

398-
if (!clearHighlights) {
398+
if (!clearHighlights && isTableVisible) {
399399
document.dispatchEvent(
400400
new CustomEvent('lv-find-results', { detail: { totalMatches: result.totalMatches } }),
401401
);
402402
}
403403
}
404404

405405
// Highlight the current row and reset the previous or next depending on whether we are stepping forward or back.
406-
if (this.totalMatches <= 0) {
406+
if (this.totalMatches <= 0 || !isTableVisible) {
407407
return;
408408
}
409409
this.blockClearHighlights = true;

log-viewer/src/features/database/components/DMLView.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@ export class DMLView extends LitElement {
6969

7070
document.addEventListener('lv-find', this._findEvt);
7171
document.addEventListener('lv-find-close', this._findEvt);
72-
document.addEventListener('lv-find-match', this._findEvt);
7372
}
7473

7574
disconnectedCallback(): void {
7675
super.disconnectedCallback();
7776
document.removeEventListener('lv-find', this._findEvt);
7877
document.removeEventListener('lv-find-close', this._findEvt);
79-
document.removeEventListener('lv-find-match', this._findEvt);
8078
}
8179

8280
updated(changedProperties: PropertyValues): void {
@@ -233,10 +231,6 @@ export class DMLView extends LitElement {
233231
}
234232

235233
const newFindArgs = JSON.parse(JSON.stringify(e.detail));
236-
if (!isTableVisible) {
237-
newFindArgs.text = '';
238-
}
239-
240234
const newSearch =
241235
newFindArgs.text !== this.findArgs.text ||
242236
newFindArgs.options.matchCase !== this.findArgs.options?.matchCase;

log-viewer/src/features/database/components/DatabaseView.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export class DatabaseView extends LitElement {
4545
document.addEventListener('lv-find', this._findHandler as EventListener);
4646
}
4747

48+
disconnectedCallback(): void {
49+
super.disconnectedCallback();
50+
document.removeEventListener('db-find-results', this._findResults as EventListener);
51+
document.removeEventListener('lv-find-match', this._findHandler as EventListener);
52+
document.removeEventListener('lv-find', this._findHandler as EventListener);
53+
}
54+
4855
static styles = [
4956
globalStyles,
5057
css`

log-viewer/src/features/database/components/SOQLView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ export class SOQLView extends LitElement {
8080

8181
document.addEventListener('lv-find', this._findEvt);
8282
document.addEventListener('lv-find-close', this._findEvt);
83-
document.addEventListener('lv-find-match', this._findEvt);
8483
}
8584

8685
disconnectedCallback(): void {
8786
super.disconnectedCallback();
8887
document.removeEventListener('lv-find', this._findEvt);
8988
document.removeEventListener('lv-find-close', this._findEvt);
90-
document.removeEventListener('lv-find-match', this._findEvt);
9189
}
9290

9391
updated(changedProperties: PropertyValues): void {
@@ -595,7 +593,7 @@ export class SOQLView extends LitElement {
595593

596594
document.dispatchEvent(
597595
new CustomEvent('db-find-results', {
598-
detail: { totalMatches: this.totalMatches, type: 'dml' },
596+
detail: { totalMatches: this.totalMatches, type: 'soql' },
599597
}),
600598
);
601599
}

log-viewer/src/tabulator/module/Find.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,18 +513,24 @@ export class Find extends Module {
513513
return String(value ?? '');
514514
}
515515

516+
// Fall back to the raw field value when the formatter result has no
517+
// extractable text. This happens for custom-element HTML strings like
518+
// <call-stack> whose content renders via shadow DOM — in a detached
519+
// element they never connect, so textContent is empty.
520+
const fallback = String(value ?? '');
521+
516522
if (typeof result === 'string') {
517523
if (result.includes('<') && result.includes('>')) {
518524
const mockElem = this._mockSearchElem;
519525
mockElem.innerHTML = result;
520526
const text = mockElem.textContent ?? '';
521527
mockElem.textContent = '';
522-
return text;
528+
return text || fallback;
523529
}
524530

525531
return result;
526532
}
527533

528-
return result?.textContent ?? '';
534+
return result?.textContent || fallback;
529535
}
530536
}

0 commit comments

Comments
 (0)