@@ -24,11 +24,12 @@ import MinMaxFilter from '../../../tabulator/filters/MinMax.js';
2424import { progressFormatter } from '../../../tabulator/format/Progress.js' ;
2525import { progressFormatterMS } from '../../../tabulator/format/ProgressMS.js' ;
2626import * as CommonModules from '../../../tabulator/module/CommonModules.js' ;
27- import { Find , formatter } from '../../../tabulator/module/Find.js' ;
27+ import { Find } from '../../../tabulator/module/Find.js' ;
2828import { MiddleRowFocus } from '../../../tabulator/module/MiddleRowFocus.js' ;
2929import { RowKeyboardNavigation } from '../../../tabulator/module/RowKeyboardNavigation.js' ;
3030import { RowNavigation } from '../../../tabulator/module/RowNavigation.js' ;
3131import dataGridStyles from '../../../tabulator/style/DataGrid.scss' ;
32+ import { createCalltreeNameFormatter } from './CalltreeNameFormatter.js' ;
3233
3334// styles
3435import { globalStyles } from '../../../styles/global.styles.js' ;
@@ -79,18 +80,27 @@ export class CalltreeView extends LitElement {
7980 return ( this . tableContainer = this . renderRoot ?. querySelector ( '#call-tree-table' ) ?? null ) ;
8081 }
8182
83+ private _goToRowEvt = ( ( e : CustomEvent ) => {
84+ this . _goToRow ( e . detail . timestamp ) ;
85+ } ) as EventListener ;
86+
8287 constructor ( ) {
8388 super ( ) ;
8489
85- document . addEventListener ( 'calltree-go-to-row' , ( ( e : CustomEvent ) => {
86- this . _goToRow ( e . detail . timestamp ) ;
87- } ) as EventListener ) ;
88-
90+ document . addEventListener ( 'calltree-go-to-row' , this . _goToRowEvt ) ;
8991 document . addEventListener ( 'lv-find' , this . _findEvt ) ;
9092 document . addEventListener ( 'lv-find-match' , this . _findEvt ) ;
9193 document . addEventListener ( 'lv-find-close' , this . _findEvt ) ;
9294 }
9395
96+ disconnectedCallback ( ) : void {
97+ super . disconnectedCallback ( ) ;
98+ document . removeEventListener ( 'calltree-go-to-row' , this . _goToRowEvt ) ;
99+ document . removeEventListener ( 'lv-find' , this . _findEvt ) ;
100+ document . removeEventListener ( 'lv-find-match' , this . _findEvt ) ;
101+ document . removeEventListener ( 'lv-find-close' , this . _findEvt ) ;
102+ }
103+
94104 updated ( changedProperties : PropertyValues ) : void {
95105 if (
96106 this . timelineRoot &&
@@ -385,34 +395,24 @@ export class CalltreeView extends LitElement {
385395 this . totalMatches = result . totalMatches ;
386396 this . findMap = result . matchIndexes ;
387397
388- if ( ! clearHighlights ) {
398+ if ( ! clearHighlights && isTableVisible ) {
389399 document . dispatchEvent (
390400 new CustomEvent ( 'lv-find-results' , { detail : { totalMatches : result . totalMatches } } ) ,
391401 ) ;
392402 }
393403 }
394404
395405 // Highlight the current row and reset the previous or next depending on whether we are stepping forward or back.
396- if ( this . totalMatches <= 0 ) {
406+ if ( this . totalMatches <= 0 || ! isTableVisible ) {
397407 return ;
398408 }
399409 this . blockClearHighlights = true ;
400- this . calltreeTable ?. blockRedraw ( ) ;
401410 const currentRow = this . findMap [ this . findArgs . count ] ;
402- const rows = [
403- currentRow ,
404- this . findMap [ this . findArgs . count + 1 ] ,
405- this . findMap [ this . findArgs . count - 1 ] ,
406- ] ;
407- rows . forEach ( ( row ) => {
408- row ?. reformat ( ) ;
411+ //@ts -expect-error This is a custom function added in by Find custom module
412+ await this . calltreeTable . setCurrentMatch ( this . findArgs . count , currentRow , {
413+ scrollIfVisible : false ,
414+ focusRow : false ,
409415 } ) ;
410-
411- if ( currentRow ) {
412- //@ts -expect-error This is a custom function added in by RowNavigation custom module
413- this . calltreeTable . goToRow ( currentRow , { scrollIfVisible : false , focusRow : false } ) ;
414- }
415- this . calltreeTable ?. restoreRedraw ( ) ;
416416 this . blockClearHighlights = false ;
417417 }
418418
@@ -580,7 +580,7 @@ export class CalltreeView extends LitElement {
580580 const excludedTypes = new Set < LogEventType > ( [ 'SOQL_EXECUTE_BEGIN' , 'DML_BEGIN' ] ) ;
581581 const governorLimits = rootMethod . governorLimits ;
582582
583- let childIndent ;
583+ const nameFormatter = createCalltreeNameFormatter ( excludedTypes ) ;
584584 this . calltreeTable = new Tabulator ( callTreeTableContainer , {
585585 data : this . _toCallTree ( rootMethod . children ) ,
586586 layout : 'fitColumns' ,
@@ -610,9 +610,6 @@ export class CalltreeView extends LitElement {
610610 return "<div class='sort-by'><div class='sort-by--top'></div><div class='sort-by--bottom'></div></div>" ;
611611 }
612612 } ,
613- rowFormatter : ( row : RowComponent ) => {
614- formatter ( row , this . findArgs ) ;
615- } ,
616613 columnCalcs : 'both' ,
617614 columnDefaults : {
618615 title : 'default' ,
@@ -630,34 +627,7 @@ export class CalltreeView extends LitElement {
630627 return 'Total' ;
631628 } ,
632629 cssClass : 'datagrid-textarea datagrid-code-text' ,
633- formatter : ( cell , _formatterParams , _onRendered ) => {
634- const cellElem = cell . getElement ( ) ;
635- const row = cell . getRow ( ) ;
636- // @ts -expect-error: _row is private. This is temporary and I will patch the text wrap behaviour in the library.
637- const dataTree = row . _row . modules . dataTree ;
638- const treeLevel = dataTree ?. index ?? 0 ;
639- childIndent ??= row . getTable ( ) . options . dataTreeChildIndent || 0 ;
640- const levelIndent = treeLevel * childIndent ;
641- cellElem . style . paddingLeft = `${ levelIndent + 4 } px` ;
642- cellElem . style . textIndent = `-${ levelIndent } px` ;
643-
644- const node = ( cell . getData ( ) as CalltreeRow ) . originalData ;
645- let text = node . text ;
646- if ( node . hasValidSymbols ) {
647- const link = document . createElement ( 'a' ) ;
648- link . setAttribute ( 'href' , '#!' ) ;
649- link . textContent = text ;
650- return link ;
651- }
652-
653- if ( node . type && ! excludedTypes . has ( node . type ) && node . type !== text ) {
654- text = node . type + ': ' + text ;
655- }
656-
657- const textSpan = document . createElement ( 'span' ) ;
658- textSpan . textContent = text ;
659- return textSpan ;
660- } ,
630+ formatter : nameFormatter ,
661631 variableHeight : true ,
662632 cellClick : ( e , cell ) => {
663633 const { type } = window . getSelection ( ) ?? { } ;
@@ -867,7 +837,14 @@ export class CalltreeView extends LitElement {
867837 this . typeFilterCache . clear ( ) ;
868838 } ) ;
869839
870- this . calltreeTable . on ( 'renderStarted' , ( ) => {
840+ this . calltreeTable . on ( 'dataSorted' , ( ) => {
841+ if ( ! this . blockClearHighlights && this . totalMatches > 0 ) {
842+ this . _resetFindWidget ( ) ;
843+ this . _clearSearchHighlights ( ) ;
844+ }
845+ } ) ;
846+
847+ this . calltreeTable . on ( 'dataFiltered' , ( ) => {
871848 if ( ! this . blockClearHighlights && this . totalMatches > 0 ) {
872849 this . _resetFindWidget ( ) ;
873850 this . _clearSearchHighlights ( ) ;
@@ -899,7 +876,7 @@ export class CalltreeView extends LitElement {
899876 this . findArgs . text = '' ;
900877 this . findArgs . count = 0 ;
901878 //@ts -expect-error This is a custom function added in by Find custom module
902- this . calltreeTable . clearFindHighlights ( Object . values ( this . findMap ) ) ;
879+ this . calltreeTable . clearFindHighlights ( ) ;
903880 this . findMap = { } ;
904881 this . totalMatches = 0 ;
905882 }
@@ -983,7 +960,7 @@ export class CalltreeView extends LitElement {
983960 }
984961 }
985962
986- private _toCallTree ( nodes : LogEvent [ ] ) : CalltreeRow [ ] | undefined {
963+ private _toCallTree ( nodes : LogEvent [ ] , treeLevel = 0 ) : CalltreeRow [ ] | undefined {
987964 const len = nodes . length ;
988965 if ( ! len ) {
989966 return undefined ;
@@ -995,12 +972,13 @@ export class CalltreeView extends LitElement {
995972 if ( ! node ) {
996973 continue ;
997974 }
998- const children = node . children . length ? this . _toCallTree ( node . children ) : null ;
975+ const children = node . children . length ? this . _toCallTree ( node . children , treeLevel + 1 ) : null ;
999976 results . push ( {
1000977 id : node . timestamp + '-' + i ,
1001978 originalData : node ,
1002979 _children : children ,
1003980 text : node . text ,
981+ treeLevel,
1004982 namespace : node . namespace ,
1005983 duration : node . duration ,
1006984 dmlCount : node . dmlCount ,
@@ -1076,6 +1054,7 @@ interface CalltreeRow {
10761054 originalData : LogEvent ;
10771055 _children : CalltreeRow [ ] | undefined | null ;
10781056 text : string ;
1057+ treeLevel : number ;
10791058 duration : CountTotals ;
10801059 namespace : string ;
10811060 dmlCount : CountTotals ;
0 commit comments