Skip to content

Commit ee60624

Browse files
committed
Fixes IE11 issues
1 parent fd9d177 commit ee60624

File tree

4 files changed

+86
-18
lines changed

4 files changed

+86
-18
lines changed

example/src/App.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,71 @@ export default class App extends Component {
2121
})
2222
}
2323
},
24+
c: {
25+
description: 'crashtest',
26+
fn: () => {
27+
return new Promise(resolve => {
28+
var x = `
29+
1234567890
30+
1234567890
31+
1234567890
32+
1234567890
33+
1234567890
34+
1234567890
35+
1234567890
36+
1234567890
37+
1234567890
38+
1dsj kfljdsafjks ladf
39+
1dsj kfljdsafjks ladf
40+
1dsj kfljdsafjks ladf
41+
1dsj kfljdsafjks ladf
42+
1dsj kfljdsafjks ladf
43+
1dsj kfljdsafjks ladf
44+
1dsj kfljdsafjks ladf
45+
1dsj kfljdsafjks ladf
46+
1dsj kfljdsafjks ladf
47+
1dsj kfljdsafjks ladf
48+
1dsj kfljdsafjks ladf
49+
1dsj kfljdsafjks ladf
50+
1dsj kfljdsafjks ladf
51+
1ksdl; fdsklajfklsadj fdsj kfljdsafjks ladf
52+
sdafjsad
53+
k fj asdpf234567890
54+
sdafjsad
55+
k fj asdpf234567890
56+
sdafjsad
57+
k fj asdpf234567890
58+
sdafjsad
59+
k fj asdpf234567890
60+
sdafjsad
61+
k fj asdpf234567890
62+
sdafjsad
63+
k fj asdpf234567890
64+
sdafjsad
65+
k fj asdpf234567890
66+
sdafjsad
67+
k fj asdpf234567890
68+
sdafjsad
69+
k fj asdpf234567890
70+
sdafjsad
71+
k fj asdpf234567890
72+
sdafjsad
73+
k fj asdpf234567890
74+
sdafjsad
75+
k fj asdpf234567890
76+
sdafjsad
77+
k fj asdpf234567890
78+
1dsj kfljdsafjks ladf
79+
sdafjsad
80+
k fj asdpf234567890
81+
sdafjsad
82+
k fj asdpf234567890
83+
84+
`
85+
resolve(x)
86+
})
87+
}
88+
},
2489
sleep: {
2590
description: 'sleep',
2691
fn: (timeout) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@webscopeio/react-console",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "React component that emulates console behaviour",
55
"author": "jvorcak",
66
"license": "MIT",

src/index.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import * as React from 'react'
66

77
import styles from './styles.css'
88

9+
// @ts-ignore
10+
const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
11+
912
export 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
}

src/styles.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
font-size: 12px;
1010
padding: 10px;
1111
height: 300px;
12-
overflow-y: auto;
1312
}
1413

1514
.promptWrapper {

0 commit comments

Comments
 (0)