From ed36538a4b2f879b2c5c37605e4616daef4ed31f Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Sun, 8 Oct 2023 19:45:13 +0200 Subject: [PATCH] Avoid rendering empty search container if site has no search plugin --- .../src/theme/Navbar/Search/index.tsx | 2 +- .../src/theme/Navbar/Search/styles.module.css | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/Search/index.tsx b/packages/docusaurus-theme-classic/src/theme/Navbar/Search/index.tsx index 236d237aa082..a720cd733a9f 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/Search/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/Search/index.tsx @@ -15,5 +15,5 @@ export default function NavbarSearch({ children, className, }: Props): JSX.Element { - return
{children}
; + return
{children}
; } diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/Search/styles.module.css b/packages/docusaurus-theme-classic/src/theme/Navbar/Search/styles.module.css index ca386bb12db9..4e0e3c3b5796 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/Search/styles.module.css +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/Search/styles.module.css @@ -5,15 +5,23 @@ * LICENSE file in the root directory of this source tree. */ +/* +Workaround to avoid rendering empty search container +See https://github.com/facebook/docusaurus/pull/7990 +*/ +.navbarSearch:not(:has(> *)) { + display: none; +} + @media (max-width: 996px) { - .searchBox { + .navbarSearch { position: absolute; right: var(--ifm-navbar-padding-horizontal); } } @media (min-width: 997px) { - .searchBox { + .navbarSearch { padding: var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal); }