Skip to content

Commit ec27ee4

Browse files
committed
update files session.component.tsx and student.component.tsx
1 parent 4d20e2e commit ec27ee4

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎front/src/pods/student/student.component.tsx‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
77

88
import * as innerClasses from './student.styles';
99

10-
1110
interface Props {
1211
room: string;
1312
log: string;
@@ -16,20 +15,24 @@ interface Props {
1615
export 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
}

‎front/src/pods/trainer/components/session.component.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ const getFullContent = (currenSessionContent: string) => {
3434
export 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
}

0 commit comments

Comments
 (0)