File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
packages/app/src/app/overmind Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,23 @@ export class VSCodeEffect {
248248 }
249249 } ;
250250
251+ public resetLayout ( ) {
252+ if ( this . editorApi ) {
253+ // We have to wait for the layout to actually update in the DOM
254+ requestAnimationFrame ( ( ) => {
255+ const rootEl = document . querySelector ( '#vscode-container' ) ;
256+ if ( rootEl ) {
257+ const boundingRect = rootEl . getBoundingClientRect ( ) ;
258+
259+ this . editorApi . editorPart . layout (
260+ boundingRect . width ,
261+ boundingRect . height
262+ ) ;
263+ }
264+ } ) ;
265+ }
266+ }
267+
251268 /*
252269 We need to use a callback to set the sandbox-fs into the state of Overmind. The reason
253270 is that we internally read from this state to get information about the files. It is really
Original file line number Diff line number Diff line change @@ -467,8 +467,9 @@ export const quickActionsClosed: Action = ({ state }) => {
467467
468468export const setPreviewContent : Action = ( ) => { } ;
469469
470- export const togglePreviewContent : Action = ( { state } ) => {
470+ export const togglePreviewContent : Action = ( { state, effects } ) => {
471471 state . editor . previewWindowVisible = ! state . editor . previewWindowVisible ;
472+ effects . vscode . resetLayout ( ) ;
472473} ;
473474
474475export const currentTabChanged : Action < {
@@ -540,13 +541,15 @@ export const deleteEnvironmentVariable: AsyncAction<{
540541 effects . codesandboxApi . restartSandbox ( ) ;
541542} ;
542543
543- export const toggleEditorPreviewLayout : Action = ( { state } ) => {
544+ export const toggleEditorPreviewLayout : Action = ( { state, effects } ) => {
544545 const currentOrientation = state . editor . previewWindowOrientation ;
545546
546547 state . editor . previewWindowOrientation =
547548 currentOrientation === WindowOrientation . VERTICAL
548549 ? WindowOrientation . HORIZONTAL
549550 : WindowOrientation . VERTICAL ;
551+
552+ effects . vscode . resetLayout ( ) ;
550553} ;
551554
552555export const previewActionReceived : Action < {
You can’t perform that action at this time.
0 commit comments