@@ -54,6 +54,7 @@ export default class Content extends React.PureComponent {
5454
5555 componentDidMount ( ) {
5656 this . fetchBundle ( ) ;
57+ setTimeout ( this . handleResize ) ;
5758 }
5859
5960 fetchBundle = ( ) => {
@@ -72,9 +73,9 @@ export default class Content extends React.PureComponent {
7273 this . setState ( { isInProjectView : view } ) ;
7374 } ;
7475
75- handleResize = ( height : number ) => {
76+ handleResize = ( height : number = 500 ) => {
77+ const extraOffset = this . props . hideNavigation ? 3 * 16 : 6 * 16 ;
7678 if ( this . props . autoResize ) {
77- const extraOffset = this . props . hideNavigation ? 3 * 16 : 6 * 16 ;
7879 window . parent . postMessage (
7980 JSON . stringify ( {
8081 src : window . location . toString ( ) ,
@@ -83,12 +84,25 @@ export default class Content extends React.PureComponent {
8384 } ) ,
8485 '*' ,
8586 ) ;
87+ } else if ( this . props . showEditor && ! this . props . showPreview ) {
88+ // If there is a focus on the editor, make it full height
89+ const editor = document . getElementsByClassName ( 'CodeMirror-sizer' ) [ 0 ] ;
90+ const editorHeight = editor ? editor . getBoundingClientRect ( ) . height : 500 ;
91+
92+ window . parent . postMessage (
93+ JSON . stringify ( {
94+ src : window . location . toString ( ) ,
95+ context : 'iframe.resize' ,
96+ height : Math . max ( editorHeight + extraOffset , 50 ) , // pixels
97+ } ) ,
98+ '*' ,
99+ ) ;
86100 } else {
87101 window . parent . postMessage (
88102 JSON . stringify ( {
89103 src : window . location . toString ( ) ,
90104 context : 'iframe.resize' ,
91- height : 500 , // pixels
105+ height, // pixels
92106 } ) ,
93107 '*' ,
94108 ) ;
@@ -166,7 +180,6 @@ export default class Content extends React.PureComponent {
166180 isInProjectView,
167181 currentModule,
168182 hideNavigation,
169- fontSize,
170183 } = this . props ;
171184
172185 const { errors } = this . state ;
0 commit comments