Skip to content

Commit e2fd355

Browse files
Keep search bar expanded when it has content
1 parent 1254a79 commit e2fd355

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

css/components/header.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
box-sizing: border-box;
2828
}
2929

30+
@media (min-width: 1040px) and (max-width: 1280px) {
31+
.site-header__container {
32+
gap: var(--space-sm);
33+
padding: 0 var(--space-md);
34+
}
35+
}
36+
3037
@media (max-width: 767px) {
3138
.site-header__container {
3239
padding: 0 var(--space-md);
@@ -153,6 +160,12 @@
153160
margin: 0;
154161
}
155162

163+
@media (max-width: 1280px) {
164+
.site-header__navigation ul {
165+
gap: var(--space-md);
166+
}
167+
}
168+
156169
.site-header__navigation li {
157170
margin: 0;
158171
padding: 0;

static/mobile-menu.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Mobile Menu Toggle - Simple and Robust
2-
31
// Wait for DOM to be fully loaded
42
document.addEventListener('DOMContentLoaded', function() {
53
const menuToggle = document.getElementById('mobile-menu-toggle');

static/search.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ const headerContainer = document.querySelector(".site-header__container");
1313
let searchItemSelected = null;
1414
let resultsItemsIndex = -1;
1515

16-
// Function to update search container class based on input content
16+
// Function to update search container class based on input content and focus
1717
function updateSearchContainerClass() {
1818
if (searchInput && searchContainer) {
19-
if (searchInput.value.trim() !== "") {
19+
const hasContent = searchInput.value.trim() !== "";
20+
const isFocused = document.activeElement === searchInput;
21+
22+
// Keep expanded if input has content OR is focused
23+
if (hasContent || isFocused) {
2024
searchContainer.classList.add("has-content");
2125
if (headerContainer) {
2226
headerContainer.classList.add("search-expanded");
@@ -213,13 +217,15 @@ function initSearch() {
213217
updateSearchContainerClass();
214218
});
215219
searchInput.addEventListener("focusin", function () {
220+
updateSearchContainerClass();
216221
if (searchInput.value !== "") {
217222
showResults(index)();
218223
}
219224
});
220225

221226
searchInput.addEventListener("focusout", function () {
222227
resultsItemsIndex = -1;
228+
updateSearchContainerClass();
223229
});
224230

225231
window.addEventListener("click", function (mouseEvent) {

templates/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<!-- Search (always visible, but styled differently on mobile) -->
2121
<div class="site-header__search">
22-
<input type="search" id="search" autocomplete="off" placeholder="Search docs and API...">
22+
<input type="search" id="search" autocomplete="off" placeholder="Search the documentation and API">
2323
<div id="search-results" class="search-results">
2424
<ul id="search-results__items" class="search-results__items"></ul>
2525
</div>

0 commit comments

Comments
 (0)