From 5058f2b4fa28f7e1dcbf92337bd01bbacc65d72b Mon Sep 17 00:00:00 2001 From: James Jensen Date: Fri, 3 Jul 2026 12:15:58 +0800 Subject: [PATCH 1/3] web: Add search field on narrow screens Cf. #640. Closes #426. This also hides all the search fields when js is disabled (since they didn't do anything anyway), and replaces "back to index" on narrow screens with a search box when js is enabled. --- support/web/js/prompt.tsx | 7 +++---- support/web/template.html | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/support/web/js/prompt.tsx b/support/web/js/prompt.tsx index 89eadbfe5..55637d2cd 100644 --- a/support/web/js/prompt.tsx +++ b/support/web/js/prompt.tsx @@ -351,10 +351,9 @@ document.addEventListener("DOMContentLoaded", () => { } }); - const searchInputProxy = document.getElementById("search-box-proxy") as HTMLInputElement | null; - if (searchInputProxy) { - searchInputProxy.addEventListener("focus", () => startSearch()); - } + document.getElementById("search-box-proxy")?.addEventListener("focus", () => startSearch()) + document.getElementById("narrow-search-box-proxy")?.addEventListener("focus", () => startSearch()) + document.addEventListener("keydown", e => { if (e.key == "k" && isShortcut(e)) { diff --git a/support/web/template.html b/support/web/template.html index b526f3fc8..8dfd4f22e 100644 --- a/support/web/template.html +++ b/support/web/template.html @@ -50,6 +50,10 @@ body span.reasoning-step .alternate { display: none; } + + .search-form { + display: none !important; + } @@ -120,11 +124,17 @@

$if(is-index)$ $else$ - + $endif$ +
+ +
+ From 6d06713c3b4042da3840f74484f03f78b6a07c0d Mon Sep 17 00:00:00 2001 From: James Jensen Date: Fri, 3 Jul 2026 16:45:07 +0800 Subject: [PATCH 2/3] fixup: Suggestions from @ncfavier --- support/web/css/default.scss | 11 +++++++++++ support/web/js/prompt.tsx | 2 +- support/web/template.html | 24 +++++++++++------------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/support/web/css/default.scss b/support/web/css/default.scss index 8753a8d2f..9da68e685 100644 --- a/support/web/css/default.scss +++ b/support/web/css/default.scss @@ -449,6 +449,17 @@ kbd { } } +#article-nav-left { + display: flex; + gap: 16px; +} + +#narrow-search-btn { + background-color: transparent; + border: none; + font-size: 24px; +} + @include mixins.widescreen { .narrow-only { diff --git a/support/web/js/prompt.tsx b/support/web/js/prompt.tsx index 55637d2cd..52d88c6ee 100644 --- a/support/web/js/prompt.tsx +++ b/support/web/js/prompt.tsx @@ -352,7 +352,7 @@ document.addEventListener("DOMContentLoaded", () => { }); document.getElementById("search-box-proxy")?.addEventListener("focus", () => startSearch()) - document.getElementById("narrow-search-box-proxy")?.addEventListener("focus", () => startSearch()) + document.getElementById("narrow-search-btn")?.addEventListener("click", () => startSearch()) document.addEventListener("keydown", e => { diff --git a/support/web/template.html b/support/web/template.html index 8dfd4f22e..df78fd9e7 100644 --- a/support/web/template.html +++ b/support/web/template.html @@ -51,7 +51,7 @@ display: none; } - .search-form { + .js-only { display: none !important; } @@ -97,7 +97,7 @@

$endif$ -
+
@@ -121,18 +121,16 @@

- - $if(is-index)$ - $else$ -