@@ -10,6 +10,8 @@ import { List } from "./List";
1010import { TimeSlicedSearch } from "./TimeSlicedSearch" ;
1111import React , { useState , useEffect , useRef , useCallback } from "react" ;
1212import { useDatamodelData , useDatamodelDataDispatch } from "@/contexts/DatamodelDataContext" ;
13+ import { updateURL } from "@/lib/url-utils" ;
14+ import { useSearchParams } from "next/navigation" ;
1315
1416export function DatamodelView ( ) {
1517 const dispatch = useSidebarDispatch ( ) ;
@@ -38,6 +40,7 @@ function DatamodelViewContent() {
3840
3941 // Calculate total search results
4042 const totalResults = filtered . length > 0 ? filtered . filter ( item => item . type === 'entity' ) . length : 0 ;
43+ const initialLocalValue = useSearchParams ( ) . get ( 'globalsearch' ) || "" ;
4144
4245 // Isolated search handlers - these don't depend on component state
4346 const handleSearch = useCallback ( ( searchValue : string ) => {
@@ -49,6 +52,7 @@ function DatamodelViewContent() {
4952 datamodelDataDispatch ( { type : "SET_FILTERED" , payload : [ ] } ) ;
5053 }
5154 }
55+ updateURL ( { query : { globalsearch : searchValue . length >= 3 ? searchValue : "" } } )
5256 datamodelDataDispatch ( { type : "SET_SEARCH" , payload : searchValue . length >= 3 ? searchValue : "" } ) ;
5357 setCurrentSearchIndex ( searchValue . length >= 3 ? 1 : 0 ) ; // Reset to first result when searching, 0 when cleared
5458 } , [ groups , datamodelDataDispatch ] ) ;
@@ -207,6 +211,7 @@ function DatamodelViewContent() {
207211 onLoadingChange = { handleLoadingChange }
208212 onNavigateNext = { handleNavigateNext }
209213 onNavigatePrevious = { handleNavigatePrevious }
214+ initialLocalValue = { initialLocalValue }
210215 currentIndex = { currentSearchIndex }
211216 totalResults = { totalResults }
212217 />
0 commit comments