From cf195da424b8d3278b2625ffcf42a8cd576f0406 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Fri, 25 Aug 2023 09:35:05 -0400 Subject: [PATCH] fix stuck search --- docs/assets/scripts/search.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/assets/scripts/search.js b/docs/assets/scripts/search.js index 049ab30a4..ead4efa0d 100644 --- a/docs/assets/scripts/search.js +++ b/docs/assets/scripts/search.js @@ -373,4 +373,12 @@ hide(); } }); + + // We're using Turbo, so when a user searches for something, visits a result, and presses the back button, the search + // UI will still be visible but not interactive. This removes the search UI when Turbo renders a page so they don't + // get trapped. + window.addEventListener('turbo:render', () => { + document.body.classList.remove('search-visible'); + document.querySelectorAll('.search__overlay, .search__dialog').forEach(el => el.remove()); + }); })();