fix: back-to-top button scrolls to search input and focuses it

When results are visible, clicking the button previously scrolled to
the results section. It now targets the search input instead, scrolls
it into view centered, and focuses it so the user can immediately type
a new query. Button label updated from 'Top' to 'Search' to reflect
the new destination.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-03-22 15:31:04 +08:00
parent d3070b735e
commit 9d89df3e73
2 changed files with 6 additions and 4 deletions

View File

@@ -351,8 +351,10 @@ if (backToTop) {
window.addEventListener('resize', updateBackToTopVisibility);
backToTop.addEventListener('click', function () {
if (!resultsSection) return;
resultsSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
var target = searchInput || resultsSection;
if (!target) return;
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
if (searchInput) searchInput.focus();
});
updateBackToTopVisibility();

View File

@@ -129,8 +129,8 @@
<th class="col-commit" data-sort="commit-time">Last Commit</th>
<th class="col-cat">Tags</th>
<th class="col-arrow">
<button class="back-to-top" aria-label="Back to library index">
Top
<button class="back-to-top" aria-label="Back to search">
Search
</button>
</th>
</tr>