File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
packages/react-devtools-shared/src/devtools/views/Components Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -49,9 +49,23 @@ export type ItemData = {
49
49
treeFocused : boolean ,
50
50
} ;
51
51
52
- type Props = { } ;
52
+ function calculateInitialScrollOffset (
53
+ inspectedElementIndex : number | null ,
54
+ elementHeight : number ,
55
+ ) : number | void {
56
+ if ( inspectedElementIndex === null ) {
57
+ return undefined ;
58
+ }
59
+
60
+ if ( inspectedElementIndex < 3 ) {
61
+ return undefined ;
62
+ }
63
+
64
+ // Make 3 elements on top of the inspected one visible
65
+ return ( inspectedElementIndex - 3 ) * elementHeight ;
66
+ }
53
67
54
- export default function Tree ( props : Props ) : React . Node {
68
+ export default function Tree ( ) : React . Node {
55
69
const dispatch = useContext ( TreeDispatcherContext ) ;
56
70
const {
57
71
numElements,
@@ -426,6 +440,10 @@ export default function Tree(props: Props): React.Node {
426
440
< FixedSizeList
427
441
className = { styles . List }
428
442
height = { height }
443
+ initialScrollOffset = { calculateInitialScrollOffset (
444
+ inspectedElementIndex ,
445
+ lineHeight ,
446
+ ) }
429
447
innerElementType = { InnerElementType }
430
448
itemCount = { numElements }
431
449
itemData = { itemData }
You can’t perform that action at this time.
0 commit comments