@@ -11,6 +11,7 @@ import { useSnackbar } from "@/contexts/SnackbarContext";
1111import { debounce , Tooltip } from '@mui/material' ;
1212
1313interface IListProps {
14+ setCurrentIndex : ( index : number ) => void ;
1415}
1516
1617// Helper to highlight search matches
@@ -21,7 +22,7 @@ export function highlightMatch(text: string, search: string) {
2122 return < > { text . slice ( 0 , idx ) } < mark className = "bg-yellow-200 text-black px-0.5 rounded" > { text . slice ( idx , idx + search . length ) } </ mark > { text . slice ( idx + search . length ) } </ > ;
2223}
2324
24- export const List = ( { } : IListProps ) => {
25+ export const List = ( { setCurrentIndex } : IListProps ) => {
2526 const dispatch = useDatamodelViewDispatch ( ) ;
2627 const { currentSection, loading } = useDatamodelView ( ) ;
2728 const { groups, filtered, search } = useDatamodelData ( ) ;
@@ -124,12 +125,15 @@ export const List = ({ }: IListProps) => {
124125 let mostVisibleEntity : {
125126 entity : EntityType ;
126127 group : GroupType ;
128+ index : number ;
127129 visibleArea : number ;
128130 } | null = null ;
129131
132+ let actualIndex = 0 ;
130133 for ( const vi of virtualItems ) {
131134 const item = flatItems [ vi . index ] ;
132135 if ( ! item || item . type !== 'entity' ) continue ;
136+ actualIndex ++ ;
133137
134138 const itemTop = vi . start ;
135139 const itemBottom = vi . end ;
@@ -148,6 +152,7 @@ export const List = ({ }: IListProps) => {
148152 mostVisibleEntity = {
149153 entity : item . entity ,
150154 group : item . group ,
155+ index : actualIndex ,
151156 visibleArea
152157 } ;
153158 }
@@ -158,6 +163,7 @@ export const List = ({ }: IListProps) => {
158163 updateURL ( { query : { group : mostVisibleEntity . group . Name , section : mostVisibleEntity . entity . SchemaName } } ) ;
159164 dispatch ( { type : "SET_CURRENT_GROUP" , payload : mostVisibleEntity . group . Name } ) ;
160165 dispatch ( { type : "SET_CURRENT_SECTION" , payload : mostVisibleEntity . entity . SchemaName } ) ;
166+ setCurrentIndex ( mostVisibleEntity . index ) ;
161167 }
162168 } , 100 ) ;
163169
0 commit comments