@@ -5,7 +5,9 @@ import { Prompt } from 'react-router-dom';
55import { reaction } from 'mobx' ;
66import { TextOperation } from 'ot' ;
77import { inject , observer } from 'mobx-react' ;
8+ import { uniqBy } from 'lodash-es' ;
89
10+ import { getSandboxOptions } from '@codesandbox/common/lib/url' ;
911import getTemplateDefinition from '@codesandbox/common/lib/templates' ;
1012import type { ModuleError } from '@codesandbox/common/lib/types' ;
1113import { getPreviewTabs } from '@codesandbox/common/lib/templates/devtools' ;
@@ -468,11 +470,28 @@ class EditorPreview extends React.Component<Props, State> {
468470 }
469471 }
470472
473+ const sandboxOptions = getSandboxOptions ( location . href ) ;
474+ if (
475+ ( sandboxOptions . previewWindow &&
476+ sandboxOptions . previewWindow === 'tests' ) ||
477+ sandboxOptions . previewWindow === 'console'
478+ ) {
479+ // Backwards compatibility for ?previewwindow=
480+
481+ view = sandboxOptions . previewWindow ;
482+ }
483+
471484 if ( view !== 'browser' ) {
472485 // Backwards compatibility for sandbox.config.json
473486 if ( view === 'console' ) {
487+ views [ 0 ] . views = views [ 0 ] . views . filter (
488+ t => t . id !== 'codesandbox.console'
489+ ) ;
474490 views [ 0 ] . views . unshift ( { id : 'codesandbox.console' } ) ;
475491 } else if ( view === 'tests' ) {
492+ views [ 0 ] . views = views [ 0 ] . views . filter (
493+ t => t . id !== 'codesandbox.tests'
494+ ) ;
476495 views [ 0 ] . views . unshift ( { id : 'codesandbox.tests' } ) ;
477496 }
478497 }
0 commit comments