Member-only story
Fix Algolia Search Box Auto-Scrolling Issue in Safari
TL;DR: Algolia’s
docsearch.js
can cause Safari to auto-scroll to the bottom after closing the search box. To fix this, add a fixed-position input field snippet (<div class="fixed"><input type="text" /></div>
) at the bottom of your HTML<body>
.
Issue Description
Algolia is a company that provides hosted search engine services widely used for technical blogs, open-source projects, and other site search solutions. Its free plan, in particular, has made it a popular choice among programming bloggers and developers.
However, when using the official docsearch.js
to create a search box, the following issue may occur in Safari: After closing the search box, the page auto-scrolls to the bottom, which severely affects the user experience.
The video below demonstrates the issue:
Stay ahead with the latest updates and deep insights on Swift, SwiftUI, Core Data, and SwiftData. Subscribe to Fatbobman’s Swift Weekly to get exclusive articles, tips, and curated resources…