Skip to content

Commit e53525c

Browse files
committed
Update resizing logic
1 parent 86f600e commit e53525c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/app/src/app/components/CodeEditor/VSCode/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class MonacoEditor extends React.Component<Props> implements Editor {
122122
this.props.height !== nextProps.height
123123
) {
124124
this.resizeEditorInstantly();
125+
126+
return true;
125127
}
126128

127129
if (
@@ -131,6 +133,8 @@ class MonacoEditor extends React.Component<Props> implements Editor {
131133
this.props.height !== nextProps.height)
132134
) {
133135
this.resizeEditorInstantly();
136+
137+
return true;
134138
}
135139

136140
const activeEditor = this.editor && this.editor.getActiveCodeEditor();
@@ -1049,9 +1053,11 @@ class MonacoEditor extends React.Component<Props> implements Editor {
10491053
};
10501054

10511055
resizeEditorInstantly = () => {
1052-
if (this.editor) {
1053-
this.editor.editorPart.layout(this.props.width, this.props.height);
1054-
}
1056+
this.forceUpdate(() => {
1057+
if (this.editor) {
1058+
this.editor.editorPart.layout(this.props.width, this.props.height);
1059+
}
1060+
});
10551061
};
10561062

10571063
/**

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,7 @@ class EditorPreview extends React.Component<Props, State> {
433433

434434
const windowVisible = store.editor.previewWindowVisible;
435435

436-
const { width: absoluteWidth, height: absoluteHeight } = this.state;
437-
438-
const editorWidth = absoluteWidth;
439-
const editorHeight = absoluteHeight;
436+
const { width: editorWidth, height: editorHeight } = this.state;
440437

441438
const template = getTemplateDefinition(sandbox.template);
442439

standalone-packages/vscode-editor/release/min/vs/editor/codesandbox.editor.main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)