@@ -14,6 +14,7 @@ import {
1414import { InterpretedResultsSortColumn , SortDirection , InterpretedResultsSortState } from '../../pure/interface-types' ;
1515import { vscode } from '../vscode-api' ;
1616import { isWholeFileLoc , isLineColumnLoc } from '../../pure/bqrs-utils' ;
17+ import { ScrollIntoViewHelper } from './scroll-into-view-helper' ;
1718
1819export type PathTableProps = ResultTableProps & { resultSet : InterpretedResultSet < SarifInterpretationData > } ;
1920export interface PathTableState {
@@ -22,6 +23,8 @@ export interface PathTableState {
2223}
2324
2425export class PathTable extends React . Component < PathTableProps , PathTableState > {
26+ private scroller = new ScrollIntoViewHelper ( ) ;
27+
2528 constructor ( props : PathTableProps ) {
2629 super ( props ) ;
2730 this . state = { expanded : new Set < string > ( ) , selectedItem : undefined } ;
@@ -211,7 +214,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
211214
212215 if ( result . codeFlows === undefined ) {
213216 rows . push (
214- < tr key = { resultIndex } { ...selectableZebraStripe ( resultRowIsSelected , resultIndex ) } >
217+ < tr ref = { this . scroller . ref ( resultRowIsSelected ) } key = { resultIndex } { ...selectableZebraStripe ( resultRowIsSelected , resultIndex ) } >
215218 < td className = "vscode-codeql__icon-cell" > { octicons . info } </ td >
216219 < td colSpan = { 3 } > { msg } </ td >
217220 { locationCells }
@@ -227,7 +230,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
227230 [ resultKey ] ;
228231
229232 rows . push (
230- < tr { ...selectableZebraStripe ( resultRowIsSelected , resultIndex ) } key = { resultIndex } >
233+ < tr ref = { this . scroller . ref ( resultRowIsSelected ) } { ...selectableZebraStripe ( resultRowIsSelected , resultIndex ) } key = { resultIndex } >
231234 < td className = "vscode-codeql__icon-cell vscode-codeql__dropdown-cell" onMouseDown = { toggler ( indices ) } >
232235 { indicator }
233236 </ td >
@@ -248,7 +251,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
248251 const indicator = currentPathExpanded ? octicons . chevronDown : octicons . chevronRight ;
249252 const isPathSpecificallySelected = Keys . equalsNotUndefined ( pathKey , selectedItem ) ;
250253 rows . push (
251- < tr { ...selectableZebraStripe ( isPathSpecificallySelected , resultIndex ) } key = { `${ resultIndex } -${ pathIndex } ` } >
254+ < tr ref = { this . scroller . ref ( isPathSpecificallySelected ) } { ...selectableZebraStripe ( isPathSpecificallySelected , resultIndex ) } key = { `${ resultIndex } -${ pathIndex } ` } >
252255 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
253256 < td className = "vscode-codeql__icon-cell vscode-codeql__dropdown-cell" onMouseDown = { toggler ( [ pathKey ] ) } > { indicator } </ td >
254257 < td className = "vscode-codeql__text-center" colSpan = { 3 } >
@@ -273,7 +276,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
273276 const stepIndex = pathNodeIndex + 1 ; // Convert to 1-based
274277 const zebraIndex = resultIndex + stepIndex ;
275278 rows . push (
276- < tr className = { isSelected ? 'vscode-codeql__selected-path-node' : undefined } key = { `${ resultIndex } -${ pathIndex } -${ pathNodeIndex } ` } >
279+ < tr ref = { this . scroller . ref ( isSelected ) } className = { isSelected ? 'vscode-codeql__selected-path-node' : undefined } key = { `${ resultIndex } -${ pathIndex } -${ pathNodeIndex } ` } >
277280 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
278281 < td className = "vscode-codeql__icon-cell" > < span className = "vscode-codeql__vertical-rule" > </ span > </ td >
279282 < td { ...selectableZebraStripe ( isSelected , zebraIndex , 'vscode-codeql__path-index-cell' ) } > { stepIndex } </ td >
@@ -349,6 +352,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
349352 expanded . delete ( Keys . keyToString ( prevState . selectedItem ) ) ;
350353 }
351354 }
355+ this . scroller . scrollIntoViewOnNextUpdate ( ) ;
352356 return {
353357 ...prevState ,
354358 expanded,
@@ -393,7 +397,12 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
393397 }
394398 }
395399
400+ componentDidUpdate ( ) {
401+ this . scroller . update ( ) ;
402+ }
403+
396404 componentDidMount ( ) {
405+ this . scroller . update ( ) ;
397406 onNavigation . addListener ( this . handleNavigationEvent ) ;
398407 }
399408
0 commit comments