Skip to content

Commit ed36538

Browse files
committed
Avoid rendering empty search container if site has no search plugin
1 parent 77b3b54 commit ed36538

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/docusaurus-theme-classic/src/theme/Navbar/Search/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export default function NavbarSearch({
1515
children,
1616
className,
1717
}: Props): JSX.Element {
18-
return <div className={clsx(className, styles.searchBox)}>{children}</div>;
18+
return <div className={clsx(className, styles.navbarSearch)}>{children}</div>;
1919
}

packages/docusaurus-theme-classic/src/theme/Navbar/Search/styles.module.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
/*
9+
Workaround to avoid rendering empty search container
10+
See https://github.com/facebook/docusaurus/pull/7990
11+
*/
12+
.navbarSearch:not(:has(> *)) {
13+
display: none;
14+
}
15+
816
@media (max-width: 996px) {
9-
.searchBox {
17+
.navbarSearch {
1018
position: absolute;
1119
right: var(--ifm-navbar-padding-horizontal);
1220
}
1321
}
1422

1523
@media (min-width: 997px) {
16-
.searchBox {
24+
.navbarSearch {
1725
padding: var(--ifm-navbar-item-padding-vertical)
1826
var(--ifm-navbar-item-padding-horizontal);
1927
}

0 commit comments

Comments
 (0)