File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 319319 </ div >
320320 </ div > <!-- Close Main Container (from Piece 1) -->
321321
322+ <!-- Interactive Client-Side Features -->
322323 <!-- Interactive Client-Side Features -->
323324 < script >
324325 /**
325326 * Real-time search engine for the report.
326- * Filters the host sections based on user search string inputs .
327+ * Filters the host sections and shifts focus dynamically .
327328 */
328329 function liveSearch ( ) {
329330 const sections = document . querySelectorAll ( '.section' ) ;
330331 const searchInput = document . getElementById ( "searchbox" ) ;
331332 if ( ! searchInput ) return ;
332333
333334 const searchQuery = searchInput . value . toLowerCase ( ) . trim ( ) ;
335+ let firstVisibleCard = null ;
334336
335337 sections . forEach ( section => {
336338 if ( searchQuery === "" || section . innerText . toLowerCase ( ) . includes ( searchQuery ) ) {
337339 section . classList . remove ( "is-hidden" ) ;
340+ // Identify the first matching host to focus on
341+ if ( ! firstVisibleCard ) {
342+ firstVisibleCard = section ;
343+ }
338344 } else {
339345 section . classList . add ( "is-hidden" ) ;
340346 }
341347 } ) ;
348+
349+ // Smoothly refocus view on the first available record during active search
350+ if ( searchQuery !== "" && firstVisibleCard ) {
351+ firstVisibleCard . scrollIntoView ( { behavior : 'auto' , block : 'nearest' } ) ;
352+ }
342353 }
343354
344355 /**
You can’t perform that action at this time.
0 commit comments