Add class search-open to body when search modal is displayed

This commit is contained in:
Samy Pessé
2023-12-18 22:03:07 +01:00
parent f3ecb69404
commit eb8baffcf8
+12
View File
@@ -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;
}