File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
77
88import * as innerClasses from './student.styles' ;
99
10-
1110interface Props {
1211 room : string ;
1312 log : string ;
@@ -16,20 +15,24 @@ interface Props {
1615export const StudentComponent : React . FC < Props > = props => {
1716 const { room, log } = props ;
1817
19- const [ autoScroll , setAutoScroll ] = React . useState ( false ) ;
18+ const [ isAutoScrollEnabled , setAutoScrollEnabled ] = React . useState ( true ) ;
2019
2120 const textAreaRef = React . useRef ( null ) ;
2221
2322 React . useEffect ( ( ) => {
24- if ( ! autoScroll )
23+ if ( isAutoScrollEnabled && textAreaRef . current ) {
2524 textAreaRef . current . scrollTop = textAreaRef . current . scrollHeight ;
25+ }
2626 } , [ log ] ) ;
2727
2828 return (
29-
3029 < >
3130 < main className = { innerClasses . root } >
32- < Typography className = { innerClasses . sessionName } variant = "body1" role = "heading" >
31+ < Typography
32+ className = { innerClasses . sessionName }
33+ variant = "body1"
34+ role = "heading"
35+ >
3336 Session name: { room ?? '' }
3437 </ Typography >
3538 < label className = { innerClasses . label } htmlFor = "session" >
@@ -47,8 +50,8 @@ export const StudentComponent: React.FC<Props> = props => {
4750 label = "Disable AutoScroll"
4851 control = {
4952 < Checkbox
50- checked = { autoScroll }
51- onChange = { e => setAutoScroll ( e . target . checked ) }
53+ checked = { isAutoScrollEnabled }
54+ onChange = { e => setAutoScrollEnabled ( e . target . checked ) }
5255 color = "primary"
5356 />
5457 }
Original file line number Diff line number Diff line change @@ -34,14 +34,15 @@ const getFullContent = (currenSessionContent: string) => {
3434export const SessionComponent : React . FC < Props > = props => {
3535 const { log, handleSendFullContentLog, className } = props ;
3636
37- const [ autoScroll , setAutoScroll ] = React . useState ( false ) ;
37+ const [ isAutoScrollEnabled , setAutoScrollEnabled ] = React . useState ( true ) ;
3838
3939 const textAreaRef = React . useRef ( null ) ;
4040
4141 React . useEffect ( ( ) => {
4242 handleSetSessionContent ( log ) ;
43- if ( ! autoScroll )
43+ if ( isAutoScrollEnabled && textAreaRef . current ) {
4444 textAreaRef . current . scrollTop = textAreaRef . current . scrollHeight ;
45+ }
4546 } , [ log ] ) ;
4647
4748 return (
@@ -61,8 +62,8 @@ export const SessionComponent: React.FC<Props> = props => {
6162 label = "Disable AutoScroll"
6263 control = {
6364 < Checkbox
64- checked = { autoScroll }
65- onChange = { e => setAutoScroll ( e . target . checked ) }
65+ checked = { isAutoScrollEnabled }
66+ onChange = { e => setAutoScrollEnabled ( e . target . checked ) }
6667 color = "primary"
6768 />
6869 }
You can’t perform that action at this time.
0 commit comments