Skip to content

Commit 8e50f51

Browse files
committed
Add focus on hosts filter
1 parent 4511225 commit 8e50f51

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

templates/report.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,26 +319,37 @@
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
/**

0 commit comments

Comments
 (0)