mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Add class search-open to body when search modal is displayed
This commit is contained in:
@@ -28,6 +28,18 @@ export function SearchModal(props: SearchModalProps) {
|
||||
[],
|
||||
);
|
||||
|
||||
// Add a global class on the body when the search modal is open
|
||||
const isSearchOpened = state !== null;
|
||||
React.useEffect(() => {
|
||||
if (isSearchOpened) {
|
||||
document.body.classList.add('search-open');
|
||||
}
|
||||
|
||||
return () => {
|
||||
document.body.classList.remove('search-open');
|
||||
};
|
||||
}, [isSearchOpened]);
|
||||
|
||||
if (state === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user