@@ -95,6 +95,9 @@ export class DatabaseView extends LitElement {
9595 width: 100%;
9696 min-height: 0%;
9797 min-width: 0%;
98+ margin-bottom: 1rem;
99+ display: flex;
100+ flex-direction: column;
98101 }
99102 ` ,
100103 ] ;
@@ -320,15 +323,13 @@ function renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]
320323 }
321324 } ) ;
322325
323- dmlTable . on ( 'groupVisibilityChanged' , ( group : GroupComponent , visible : boolean ) => {
324- const firstRow = visible ? group . getRows ( ) [ 0 ] : group . getRows ( ) [ 0 ] . getPrevRow ( ) ;
325- if ( firstRow ) {
326- // @ts -expect-error it has 2 params
327- firstRow . scrollTo ( 'center' , true ) . then ( ( ) => {
328- firstRow
329- . getElement ( )
330- . scrollIntoView ( { behavior : 'auto' , block : 'center' , inline : 'start' } ) ;
331- } ) ;
326+ dmlTable . on ( 'groupVisibilityChanged' , ( group : GroupComponent , _visible : boolean ) => {
327+ const groupToFocus = group . getElement ( ) ? group : findGroup ( soqlTable , group . getKey ( ) ) ;
328+
329+ if ( groupToFocus ) {
330+ groupToFocus
331+ . getElement ( )
332+ . scrollIntoView ( { behavior : 'instant' , block : 'center' , inline : 'start' } ) ;
332333 }
333334 } ) ;
334335
@@ -337,18 +338,13 @@ function renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]
337338 if ( ! ( data . timestamp && data . dml ) ) {
338339 return ;
339340 }
340- const origRowHeight = row . getElement ( ) . offsetHeight ;
341341
342+ const origRowHeight = row . getElement ( ) . offsetHeight ;
342343 row . treeToggle ( ) ;
343- row . getCell ( 'soql ' ) . getElement ( ) . style . height = origRowHeight + 'px' ;
344+ row . getCell ( 'dml ' ) . getElement ( ) . style . height = origRowHeight + 'px' ;
344345
345- const nextRow = row . getNextRow ( ) || row . getTreeChildren ( ) [ 0 ] ;
346- if ( nextRow ) {
347- // @ts -expect-error it has 2 params
348- nextRow . scrollTo ( 'center' , true ) . then ( ( ) => {
349- nextRow . getElement ( ) . scrollIntoView ( { behavior : 'auto' , block : 'center' , inline : 'start' } ) ;
350- } ) ;
351- }
346+ row &&
347+ row . getElement ( ) . scrollIntoView ( { behavior : 'instant' , block : 'center' , inline : 'start' } ) ;
352348 } ) ;
353349}
354350
@@ -598,15 +594,13 @@ function renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecute
598594 }
599595 } ) ;
600596
601- soqlTable . on ( 'groupVisibilityChanged' , ( group : GroupComponent , visible : boolean ) => {
602- const firstRow = visible ? group . getRows ( ) [ 0 ] : group . getRows ( ) [ 0 ] . getPrevRow ( ) ;
603- if ( firstRow ) {
604- // @ts -expect-error it has 2 params
605- firstRow . scrollTo ( 'center' , true ) . then ( ( ) => {
606- firstRow
607- . getElement ( )
608- . scrollIntoView ( { behavior : 'auto' , block : 'center' , inline : 'start' } ) ;
609- } ) ;
597+ soqlTable . on ( 'groupVisibilityChanged' , ( group : GroupComponent , _visible : boolean ) => {
598+ const groupToFocus = group . getElement ( ) ? group : findGroup ( soqlTable , group . getKey ( ) ) ;
599+
600+ if ( groupToFocus ) {
601+ groupToFocus
602+ . getElement ( )
603+ . scrollIntoView ( { behavior : 'instant' , block : 'center' , inline : 'start' } ) ;
610604 }
611605 } ) ;
612606
@@ -617,17 +611,11 @@ function renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecute
617611 }
618612
619613 const origRowHeight = row . getElement ( ) . offsetHeight ;
620-
621614 row . treeToggle ( ) ;
622615 row . getCell ( 'soql' ) . getElement ( ) . style . height = origRowHeight + 'px' ;
623616
624- const nextRow = row . getNextRow ( ) || row . getTreeChildren ( ) [ 0 ] ;
625- if ( nextRow ) {
626- // @ts -expect-error it has 2 params
627- nextRow . scrollTo ( 'center' , true ) . then ( ( ) => {
628- nextRow . getElement ( ) . scrollIntoView ( { behavior : 'auto' , block : 'center' , inline : 'start' } ) ;
629- } ) ;
630- }
617+ row &&
618+ row . getElement ( ) . scrollIntoView ( { behavior : 'instant' , block : 'center' , inline : 'start' } ) ;
631619 } ) ;
632620}
633621
@@ -689,3 +677,18 @@ function downlodEncoder(defaultFileName: string) {
689677 return new Blob ( [ fileContents ] , { type : mimeType } ) ;
690678 } ;
691679}
680+
681+ function findGroup ( table : Tabulator , groupKey : string ) : GroupComponent | null {
682+ let foundGroup = null ;
683+ const groups = soqlTable . getGroups ( ) ;
684+ let len = groups ?. length - 1 || 0 ;
685+ while ( len >= 0 && ! foundGroup ) {
686+ const toSearch = groups [ len ] ;
687+ if ( toSearch . getKey ( ) === groupKey ) {
688+ foundGroup = toSearch ;
689+ break ;
690+ }
691+ len -- ;
692+ }
693+ return foundGroup ;
694+ }
0 commit comments