Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,60 @@ html {
position: relative;
}

/* Transfer the search-area visual chrome (background, bottom border, top radius)
from .DocSearch-Form to .DocSearch-SearchBar now that our custom controls are
siblings of the form rather than children of it. */
.DocSearch-SearchBar {
background: var(--docsearch-searchbox-focus-background);
border-bottom: 1px solid var(--docsearch-subtle-color);
border-radius: 4px 4px 0 0;
align-items: center;
}

/* Fix .DocSearch-Title — the library sets line-height: 0.5em which causes
wrapped lines to overlap, and no word-break so long queries overflow horizontally. */
.DocSearch-Title {
line-height: 1.4 !important;
white-space: normal !important;
word-break: break-word;
overflow-wrap: break-word;
}

/* Hide the "close the query" text label — keep only the × icon.
!important is needed because DocSearch styles are dynamically imported
after our CSS, so they would otherwise win the cascade. */
.DocSearch-Clear {
font-size: 0 !important;
}
.DocSearch-Clear span {
display: none;
}

/* Strip the duplicate chrome from the form itself. */
.DocSearch-Form {
flex: 1 1 auto;
width: auto;
background: transparent;
border-block-end: none !important;
border-radius: 0;
}

/* On mobile, wrap the custom controls onto their own row below the search input. */
@media (max-width: 768px) {
.DocSearch-SearchBar {
flex-wrap: wrap;
}

.search-custom-controls {
flex: 0 0 100%;
margin-right: 0 !important;
padding: 6px 16px 8px;
border-bottom: 1px solid var(--docsearch-subtle-color);
}


}

/* Responsive improvements */
@media (max-width: 768px) {
.DocSearch-Button-Keys {
Expand Down
13 changes: 4 additions & 9 deletions src/theme/SearchBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,24 +686,18 @@ export default function SearchBar() {
const [modalHeaderEl, setModalHeaderEl] = useState(null);

const onModalOpen = useCallback(() => {
// Try to locate the header/searchbar area in the DocSearch modal.
// DocSearch v3 uses these classnames.
// Target .DocSearch-SearchBar so our controls are a sibling of .DocSearch-Form.
// This lets us move them below the search row on mobile via flex-wrap.
const el =
document.querySelector('.DocSearch-SearchBar') ||
document.querySelector('.DocSearch-Form') ||
document.querySelector('.DocSearch-Modal');

setModalHeaderEl(el || null);
}, []);

// When modalHeaderEl exists, insert filters BEFORE the form input if possible.
// We target .DocSearch-Form when present, otherwise the container itself.
const portalTarget = useMemo(() => {
if (!modalHeaderEl) return null;
return (
modalHeaderEl.querySelector('.DocSearch-Form') ||
modalHeaderEl
);
return modalHeaderEl;
}, [modalHeaderEl]);

// Keep contextualSearch stable to prevent query reset
Expand All @@ -724,6 +718,7 @@ export default function SearchBar() {
createPortal(
// Wrapper to align with DocSearch input
<div
className="search-custom-controls"
style={{
display: 'flex',
alignItems: 'center',
Expand Down
Loading