File tree Expand file tree Collapse file tree
packages/react-devtools-shared/src/devtools/views/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,9 +49,23 @@ export type ItemData = {
4949 treeFocused : boolean ,
5050} ;
5151
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+ }
5367
54- export default function Tree ( props : Props ) : React . Node {
68+ export default function Tree ( ) : React . Node {
5569 const dispatch = useContext ( TreeDispatcherContext ) ;
5670 const {
5771 numElements,
@@ -426,6 +440,10 @@ export default function Tree(props: Props): React.Node {
426440 < FixedSizeList
427441 className = { styles . List }
428442 height = { height }
443+ initialScrollOffset = { calculateInitialScrollOffset (
444+ inspectedElementIndex ,
445+ lineHeight ,
446+ ) }
429447 innerElementType = { InnerElementType }
430448 itemCount = { numElements }
431449 itemData = { itemData }
You can’t perform that action at this time.
0 commit comments