From 8c2360a714e39651165d591124cf77a772f26fce Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 3 Mar 2026 17:50:54 -0400 Subject: client: sidebar-search: bound session storage, resilient time travel This is essentially the best we can get without taking advantage of literally brand new navigation APIs, if we don't want to get reeeeeeeeeeally futzy. This approach is strictly oriented around the back/forward cache and does not store anything in history state (replaceState etc). --- src/static/js/client/sidebar-search.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/static/js/client/sidebar-search.js') diff --git a/src/static/js/client/sidebar-search.js b/src/static/js/client/sidebar-search.js index 3cc3d218..0b905948 100644 --- a/src/static/js/client/sidebar-search.js +++ b/src/static/js/client/sidebar-search.js @@ -158,6 +158,17 @@ export const info = { }, }; +export function* bindSessionStorage() { + if (yield 'activeQuery') { + yield 'activeQueryContextPageName'; + yield 'activeQueryContextPagePathname'; + yield 'activeQueryContextPageColor'; + yield 'activeQueryResults'; + yield 'activeFilterType'; + yield 'resultsScrollOffset'; + } +} + export function getPageReferences() { info.pageContainer = document.getElementById('page-container'); @@ -443,6 +454,12 @@ export function mutatePageContent() { info.searchBox.appendChild(info.endSearchRule); info.searchBox.appendChild(info.endSearchLine); + + // Accommodate the web browser reconstructing the search input with a value + // that was previously entered (or restored after recall), i.e. because + // the user is traversing very far back in history and yet the browser is + // trying to rebuild the page as-was anyway, by telling it "no don't". + info.searchInput.value = ''; } export function addPageListeners() { -- cgit 1.3.0-6-gf8a5