@@ -5,6 +5,7 @@ import { listUnordered } from "./octicons";
55import { ScrollIntoViewHelper } from "./scroll-into-view-helper" ;
66import { selectableZebraStripe } from "./result-table-utils" ;
77import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell" ;
8+ import { useMemo } from "react" ;
89
910interface Props {
1011 result : Sarif . Result ;
@@ -29,15 +30,16 @@ export function AlertTableResultRow(props: Props) {
2930 locationCells,
3031 } = props ;
3132
32- const resultKey : Keys . Result = { resultIndex } ;
33-
34- const paths : Sarif . ThreadFlow [ ] = Keys . getAllPaths ( result ) ;
35- const indices =
36- paths . length === 1
37- ? [ resultKey , { ...resultKey , pathIndex : 0 } ]
38- : /* if there's exactly one path, auto-expand
39- * the path when expanding the result */
40- [ resultKey ] ;
33+ const handleDropdownClick = useMemo ( ( ) => {
34+ const resultKey : Keys . Result = { resultIndex } ;
35+ const indices =
36+ Keys . getAllPaths ( result ) . length === 1
37+ ? [ resultKey , { ...resultKey , pathIndex : 0 } ]
38+ : /* if there's exactly one path, auto-expand
39+ * the path when expanding the result */
40+ [ resultKey ] ;
41+ return toggler ( indices ) ;
42+ } , [ result , resultIndex , toggler ] ) ;
4143
4244 const resultRowIsSelected =
4345 selectedItem ?. resultIndex === resultIndex &&
@@ -51,7 +53,7 @@ export function AlertTableResultRow(props: Props) {
5153 >
5254 < AlertTableDropdownIndicatorCell
5355 expanded = { currentResultExpanded }
54- onClick = { toggler ( indices ) }
56+ onClick = { handleDropdownClick }
5557 />
5658 < td className = "vscode-codeql__icon-cell" > { listUnordered } </ td >
5759 < td colSpan = { 2 } > { msg } </ td >
0 commit comments