Skip to content

Commit 8fc9dd6

Browse files
feat: Dynamically resize search drawer on mobile (#411)
| Full screen | With keyboard visible | |----------|----------| | <img width="1008" height="2007" alt="image" src="https://github.com/user-attachments/assets/381fc87a-dac0-4f0b-b84b-d8db6971c294" /> | <img width="1008" height="2003" alt="image" src="https://github.com/user-attachments/assets/a3fd65f1-edd0-403a-84a2-11a128686b84" /> | --------- Co-authored-by: Robert Schuster <77234379+therobrob@users.noreply.github.com>
1 parent a866f15 commit 8fc9dd6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

assets/js/search.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ const initSearch = () => {
2727
},
2828
});
2929

30+
// Close keyboard when scrolling in search results (mobile only)
31+
const searchDrawer = search.querySelector(".pagefind-ui__drawer");
32+
searchDrawer.addEventListener("scroll", () => {
33+
if (!isMobile) return;
34+
if (document.activeElement && document.activeElement.blur) {
35+
document.activeElement.blur();
36+
}
37+
});
38+
3039
const searchElement = search.querySelector("input");
3140

3241
const closeSearch = () => {

assets/sass/search.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
z-index: 6;
7676
border: var(--border);
7777
border-radius: 0 0 var(--border-radius-l) var(--border-radius-l);
78+
79+
@media (max-width: #{$breakpoint-md}) {
80+
max-height: calc(100dvh - 17rem);
81+
}
7882
}
7983

8084
.pagefind-ui__result {

layouts/partials/headMeta.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta name="dc.relation" content="{{ .Site.BaseURL }}" />
44
<meta
55
name="viewport"
6-
content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"
6+
content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover, interactive-widget=resizes-content"
77
/>
88
<meta name="theme-color" content="#BA3D12" />
99
<meta property="og:url" content="{{ .Permalink }}" />

0 commit comments

Comments
 (0)