From 2eebfde8847d9115b92ad7bc0c0e29857fb91c91 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 19 Sep 2026 14:04:12 +0100 Subject: [PATCH] fix(nav): close the site menu when search opens The menu is a popover, so the browser draws it above the DocSearch modal. Opening search from the menu left the menu sitting on top of the search box on desktop and mobile. Clicking Search now closes the menu in the same click handler. For Cmd+K and /, DocSearch's onOpen callback fires a docsearch:open event that the menu listens for. Co-Authored-By: Claude Opus 5 (1M context) --- resources/js/app.js | 3 + .../components/navbar/mobile-menu.blade.php | 6 +- .../NavigationMobileMenuSearchTest.php | 56 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/NavigationMobileMenuSearchTest.php diff --git a/resources/js/app.js b/resources/js/app.js index 57cb6ced0..b94b2ae99 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -189,6 +189,9 @@ const docsearchOptions = { docsearch({ ...docsearchOptions, container: '#docsearch-desktop', + // The site menu is a popover, so it renders above the search modal. Tell it + // to close when a keyboard shortcut opens search while the menu is open. + onOpen: () => window.dispatchEvent(new CustomEvent('docsearch:open')), }) // Mirror the desktop DocSearch button into the mobile container so that diff --git a/resources/views/components/navbar/mobile-menu.blade.php b/resources/views/components/navbar/mobile-menu.blade.php index 5ca02d30b..ff1b9fd25 100644 --- a/resources/views/components/navbar/mobile-menu.blade.php +++ b/resources/views/components/navbar/mobile-menu.blade.php @@ -42,6 +42,7 @@ }) } " + x-on:docsearch:open.window="showMobileMenu = false" class="relative z-40" >