search results box is the right size now

This commit is contained in:
2026-05-05 09:57:26 -04:00
parent 9042468fe8
commit b1b81a04ed
2 changed files with 34 additions and 12 deletions

View File

@@ -60,12 +60,6 @@ var Search = (function() {
// Insert after brand
brand.parentNode.insertBefore(searchWrapper, brand.nextSibling);
// Move results container inside search wrapper for correct absolute positioning
var existingContainer = document.getElementById('searchResultsContainer');
if (existingContainer) {
searchWrapper.appendChild(existingContainer);
}
currentInput = searchInput;
// Event listeners
@@ -118,6 +112,25 @@ var Search = (function() {
hideDropdown();
}
});
// Reposition on scroll and resize
function positionDropdown() {
var container = document.getElementById('searchResultsContainer');
if (!container || !dropdownVisible) return;
var rect = currentInput.getBoundingClientRect();
var vw = window.innerWidth;
container.style.top = (rect.bottom + 5) + 'px';
if (vw <= 900) {
container.style.left = '0';
container.style.width = '100vw';
} else {
container.style.left = rect.left + 'px';
container.style.width = '520px';
}
}
window.addEventListener('scroll', positionDropdown);
window.addEventListener('resize', positionDropdown);
}
function crawlPage(url, callback) {
@@ -453,6 +466,18 @@ var Search = (function() {
function showDropdown() {
var container = document.getElementById('searchResultsContainer');
if (container) {
var rect = currentInput.getBoundingClientRect();
var vw = window.innerWidth;
var sidebarWidth = 240;
if (vw <= 900) {
container.style.left = '0';
container.style.width = '100vw';
} else {
container.style.left = rect.left + 'px';
container.style.width = '520px';
}
container.style.top = (rect.bottom + 5) + 'px';
container.style.display = 'block';
dropdownVisible = true;
}