Skip to content

Commit bce7f35

Browse files
committed
Fixes scrolling issue
1 parent ee60624 commit bce7f35

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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.10",
3+
"version": "1.0.11",
44
"description": "React component that emulates console behaviour",
55
"author": "jvorcak",
66
"license": "MIT",

src/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export default class ReactConsole extends React.Component<Props, State> {
5555
this.setState({output: [], input: ''})
5656
};
5757

58+
scrollToBottom = () => {
59+
setTimeout(() => {
60+
this.wrapperRef.scrollTop = this.wrapperRef.scrollHeight
61+
})
62+
};
63+
5864
onSubmit = async (e: any) => {
5965
const {prompt} = this.props;
6066
e.preventDefault();
@@ -71,6 +77,7 @@ export default class ReactConsole extends React.Component<Props, State> {
7177
output: [...this.state.output, log],
7278
input: '',
7379
});
80+
this.scrollToBottom()
7481
return
7582
}
7683

@@ -98,6 +105,7 @@ export default class ReactConsole extends React.Component<Props, State> {
98105
}
99106
this.setState({commandInProgress: false, input: ''});
100107
this.inputRef.focus()
108+
this.scrollToBottom()
101109
};
102110

103111
render() {

0 commit comments

Comments
 (0)