Skip to content

Commit 4e4c30e

Browse files
author
Ives van Hoorne
committed
Fix external window not updating if preview is hidden
1 parent e5dbe93 commit 4e4c30e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/app/src/app/components/Preview/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Props = {
3131
showNavigation?: boolean,
3232
inactive?: boolean,
3333
dragging?: boolean,
34+
hide: boolean,
3435
};
3536

3637
type State = {
@@ -315,10 +316,15 @@ class BasePreview extends React.Component<Props, State> {
315316
settings,
316317
isInProjectView,
317318
dragging,
319+
hide,
318320
} = this.props;
319321
const { historyPosition, history, urlInAddressBar } = this.state;
320322
const url = urlInAddressBar || frameUrl(sandbox.id);
321323

324+
if (hide) {
325+
return null;
326+
}
327+
322328
return (
323329
<Container style={{ flex: 1 }}>
324330
{showNavigation && (

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/FlyingContainer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class FlyingContainer extends React.Component<Props, State> {
208208
};
209209

210210
render() {
211+
const { hide } = this.props;
211212
const { previewWindow } = this.props.store.editor;
212213

213214
const width = this.state.width || previewWindow.width;
@@ -243,9 +244,12 @@ class FlyingContainer extends React.Component<Props, State> {
243244
width: width || '50%',
244245
flex: width ? `0 0 ${width}px` : undefined,
245246
height,
246-
boxShadow: '0 3px 8px rgba(0, 0, 0, 0.5)',
247+
boxShadow: hide ? 'none' : '0 3px 8px rgba(0, 0, 0, 0.5)',
247248
zIndex: 60,
248249
cursor: 'move',
250+
251+
visiblity: hide ? 'hidden' : undefined,
252+
pointerEvents: hide ? 'none' : undefined,
249253
}}
250254
ref={this.updateBounds}
251255
>

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,10 @@ class Preview extends React.Component<Props, State> {
220220
code: store.editor.currentPackageJSONCode,
221221
};
222222

223-
if (!store.editor.previewWindow.content) {
224-
return null;
225-
}
223+
const hide = !store.editor.previewWindow.content;
226224

227225
return (
228-
<FlyingContainer onPositionChange={this.resetAlignment}>
226+
<FlyingContainer hide={hide} onPositionChange={this.resetAlignment}>
229227
{({ resize }) => (
230228
<BasePreview
231229
onInitialized={this.onPreviewInitialized}
@@ -239,6 +237,7 @@ class Preview extends React.Component<Props, State> {
239237
onAction={action =>
240238
signals.editor.previewActionReceived({ action })
241239
}
240+
hide={hide}
242241
onOpenNewWindow={() =>
243242
this.props.signals.preferences.viewModeChanged({
244243
showEditor: true,

0 commit comments

Comments
 (0)