@@ -6,6 +6,9 @@ import * as React from 'react'
66
77import styles from './styles.css'
88
9+ // @ts -ignore
10+ const isIE11 = ! ! window . MSInputMethodContext && ! ! document . documentMode ;
11+
912export type Props = {
1013 text : string ,
1114 prompt : string ,
@@ -63,7 +66,7 @@ export default class ReactConsole extends React.Component<Props, State> {
6366
6467 const log = `${ prompt } \xa0${ inputString } ` ;
6568
66- if ( inputString === '' ) {
69+ if ( inputString === '' ) {
6770 this . setState ( {
6871 output : [ ...this . state . output , log ] ,
6972 input : '' ,
@@ -73,26 +76,20 @@ export default class ReactConsole extends React.Component<Props, State> {
7376
7477 const [ cmd , ...args ] = inputString . split ( " " ) ;
7578
76- if ( cmd === 'clear' ) {
79+ if ( cmd === 'clear' ) {
7780 this . clear ( ) ;
7881 return
7982 }
8083
8184 const command = this . props . commands [ cmd ] ;
8285
83-
84- await this . setState ( { commandInProgress : true } ) ;
86+ this . setState ( { commandInProgress : true } ) ;
8587
8688 if ( command ) {
87- try {
88- const ret = await command . fn ( ...args ) ;
89- await this . setState ( {
90- output : [ ...this . state . output , log , ret ]
91- } )
92- } catch ( err ) {
93-
94- }
95-
89+ const ret = await command . fn ( ...args ) ;
90+ this . setState ( {
91+ output : [ ...this . state . output , log , ret ]
92+ } )
9693 } else {
9794 const cmdNotFound = await this . props . noCommandFound ( cmd , ...args ) ;
9895 this . setState ( {
@@ -115,7 +112,14 @@ export default class ReactConsole extends React.Component<Props, State> {
115112 : styles . prompt ;
116113
117114 return (
118- < div className = { styles . wrapper } onClick = { this . focusConsole } ref = { ref => this . wrapperRef = ref } >
115+ < div
116+ className = { styles . wrapper }
117+ onClick = { this . focusConsole }
118+ ref = { ref => this . wrapperRef = ref }
119+ style = { {
120+ overflowY : isIE11 ? "scroll" : "auto" ,
121+ } }
122+ >
119123 < div >
120124 { this . state . output . map ( ( line , key ) =>
121125 < pre
@@ -157,8 +161,8 @@ export default class ReactConsole extends React.Component<Props, State> {
157161 } ;
158162
159163 focusConsole = ( ) => {
160- if ( this . inputRef ) {
161- if ( document . getSelection ( ) . isCollapsed ) {
164+ if ( this . inputRef ) {
165+ if ( document . getSelection ( ) . isCollapsed ) {
162166 this . inputRef . focus ( )
163167 }
164168 }
0 commit comments