Skip to content

Commit fc38e0c

Browse files
committed
[site] Search fix
1 parent f30a6a2 commit fc38e0c

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎site/js/common/search.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ export const searchLoad = (isHome = false) => {
113113
nav.prepend(search);
114114
const showResults = () =>
115115
(input.value ? addClass : delClass)(results, 'show');
116-
input.addEventListener('focus', showResults);
116+
input.addEventListener('focus', () => {
117+
// The search box sits beside the menu here, so close the menu.
118+
if (matchMedia('(min-width: 38rem)').matches) {
119+
(doc.getElementById('menustate') as HTMLInputElement).checked = false;
120+
}
121+
showResults();
122+
});
117123
input.addEventListener('input', () => {
118124
showResults();
119125
populateResults();

‎site/less/header.less‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ body:not(.home) > header {
201201
> nav > ul {
202202
display: none;
203203
}
204+
// Keep the search results on the screen, now the search is at the right.
205+
> nav > #search > ol {
206+
right: 0;
207+
}
208+
// The menu and the search results would overlap, so only show one.
209+
> #menustate:checked ~ nav > #search > ol {
210+
display: none;
211+
}
204212
> #menustate:checked ~ nav > ul {
205213
.dropdown();
206214
display: block;
@@ -226,9 +234,13 @@ body:not(.home) > header {
226234
width: 100%;
227235
max-width: unset;
228236
}
237+
> ol.show {
238+
display: block;
239+
}
229240
}
230241
> ul {
231242
position: static;
243+
z-index: auto;
232244
width: auto;
233245
padding: 0;
234246
border: 0;

‎site/less/theme.less‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ body {
4242
z-index: 1;
4343
}
4444
> header {
45+
// Above the footer, so that the menu and search results can overlap it.
46+
z-index: 2;
4547
border-bottom: 1px solid @borderColor;
4648
box-shadow: @shadow;
4749
}

0 commit comments

Comments
 (0)