Skip to content

Commit d613519

Browse files
committed
Scroll into the table after search
1 parent cfed2de commit d613519

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/app/page.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ function SearchInterface() {
208208
}
209209

210210
setLoading(false);
211+
212+
// Scroll to results after search completion
213+
setTimeout(() => {
214+
const resultsSection = document.querySelector("#search-results");
215+
if (resultsSection) {
216+
resultsSection.scrollIntoView({ behavior: "smooth", block: "start" });
217+
}
218+
}, 100);
211219
};
212220

213221
const handleSubmit = async (e: React.FormEvent) => {
@@ -403,7 +411,7 @@ function SearchInterface() {
403411
</div>
404412

405413
{loading && (
406-
<div className="bg-white rounded-lg shadow-lg border border-gray-200 p-4 md:p-8 mb-6 mx-2">
414+
<div className="bg-white rounded-lg shadow-lg border border-gray-200 p-4 md:p-8 mb-6">
407415
<div className="flex items-center justify-center">
408416
<div className="animate-spin rounded-full h-6 md:h-8 w-6 md:w-8 border-b-2 border-cerulean-blue-600"></div>
409417
<span className="ml-3 text-sm md:text-base text-gray-600">Searching...</span>
@@ -412,16 +420,16 @@ function SearchInterface() {
412420
)}
413421

414422
{error && (
415-
<div className="bg-red-50 border border-red-200 rounded-lg p-4 mb-6 mx-2">
423+
<div className="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">
416424
<div className="text-red-800 font-medium text-sm md:text-base">Error</div>
417425
<div className="text-red-700 text-xs md:text-sm mt-1">{error}</div>
418426
</div>
419427
)}
420428

421429
{!loading && results && results.length === 0 && query.trim() && !error && (
422-
<div className="bg-gray-50 border border-gray-200 rounded-lg p-6 mb-6 mx-2 text-center">
430+
<div id="search-results" className="bg-gray-50 border border-gray-200 rounded-lg p-6 mb-6 text-center">
423431
<div className="text-gray-600 text-sm md:text-base">
424-
No results found for <span className="font-mono font-semibold">"{query}"</span>
432+
No results found for <span className="font-mono font-semibold">&quot;{query}&quot;</span>
425433
</div>
426434
<div className="text-gray-500 text-xs md:text-sm mt-2">
427435
Try using wildcards (*) or check your search syntax
@@ -431,15 +439,15 @@ function SearchInterface() {
431439

432440
{!loading && results && results.length > 0 && (
433441
<>
434-
<div className="text-xs md:text-sm text-gray-600 px-2 mb-2">
442+
<div id="search-results" className="text-xs md:text-sm text-gray-600 mb-2">
435443
Showing {results.length} result{results.length > 1 ? "s" : ""}
436444
</div>
437445
{results.length && results.length % 100 === 0 && (
438-
<div className="text-xs md:text-sm text-gray-600 px-2 mb-4">
446+
<div className="text-xs md:text-sm text-gray-600 mb-4">
439447
Results are limited to 100 for each type. Try to be more specific with the query.
440448
</div>
441449
)}
442-
<div className="bg-white rounded-lg shadow-lg border border-gray-200 overflow-hidden mx-2">
450+
<div className="bg-white rounded-lg shadow-lg border border-gray-200 overflow-hidden">
443451
<div className="overflow-x-auto">
444452
<table className="w-full">
445453
<thead className="bg-cerulean-blue-500 text-white">

0 commit comments

Comments
 (0)