Skip to content

Commit 292ca31

Browse files
authored
Merge pull request #3797 from processing/modal-visibility
Fixes IDE Overlays Leading to a White Screen
2 parents 06c0851 + c664b63 commit 292ca31

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

client/modules/App/components/Overlay.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useRef } from 'react';
2-
import MediaQuery from 'react-responsive';
2+
import { useMediaQuery } from 'react-responsive';
33
import { useSelector } from 'react-redux';
44
import { useHistory } from 'react-router-dom';
55
import { useTranslation } from 'react-i18next';
@@ -9,8 +9,8 @@ import type { RootState } from '../../../reducers';
99
import ExitIcon from '../../../images/exit.svg';
1010

1111
type OverlayProps = {
12-
children?: React.ReactElement;
13-
actions?: React.ReactElement;
12+
children?: React.ReactNode;
13+
actions?: React.ReactNode;
1414
closeOverlay?: () => void;
1515
title?: string;
1616
ariaLabel?: string;
@@ -35,6 +35,9 @@ export const Overlay = ({
3535

3636
const browserHistory = useHistory();
3737

38+
const isDesktop = useMediaQuery({ minWidth: 770 });
39+
const isMobile = useMediaQuery({ maxWidth: 769 });
40+
3841
const close = useCallback(() => {
3942
const node = ref.current;
4043
if (!node) return;
@@ -66,7 +69,7 @@ export const Overlay = ({
6669
<header className="overlay__header">
6770
<h2 className="overlay__title">{title}</h2>
6871
<div className="overlay__actions">
69-
<MediaQuery minWidth={770}>{actions}</MediaQuery>
72+
{isDesktop && actions}
7073
<button
7174
className="overlay__close-button"
7275
onClick={close}
@@ -76,11 +79,9 @@ export const Overlay = ({
7679
</button>
7780
</div>
7881
</header>
79-
<MediaQuery maxWidth={769}>
80-
{actions && (
81-
<div className="overlay__actions-mobile">{actions}</div>
82-
)}
83-
</MediaQuery>
82+
{isMobile && actions && (
83+
<div className="overlay__actions-mobile">{actions}</div>
84+
)}
8485
{children}
8586
</section>
8687
</div>

0 commit comments

Comments
 (0)