Skip to content

Commit eeaa585

Browse files
authored
Merge pull request #150 from Lemoncode/feature/#149-a11y-add-role-log
Feature/#149 a11y add role log
2 parents 8fabf24 + 0983d29 commit eeaa585

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('StudentComponent tests', () => {
1717

1818
// Assert
1919
const sessionName = screen.getByRole('heading');
20-
const textArea = screen.getByRole('textbox');
20+
const textArea = screen.getByRole('log');
2121

2222
expect(sessionName).toHaveTextContent(expectedSessionNameText);
2323
expect(textArea).toHaveValue(props.log);
@@ -69,7 +69,7 @@ describe('StudentComponent tests', () => {
6969
render(<StudentComponent {...props} />);
7070

7171
// Assert
72-
const textArea = screen.getByRole('textbox');
72+
const textArea = screen.getByRole('log');
7373
expect(textArea).toHaveTextContent('');
7474
});
7575

@@ -84,7 +84,7 @@ describe('StudentComponent tests', () => {
8484
render(<StudentComponent {...props} />);
8585

8686
// Assert
87-
const textArea = screen.getByRole('textbox');
87+
const textArea = screen.getByRole('log');
8888
expect(textArea).toHaveTextContent('');
8989
});
9090
});

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,39 @@ interface Props {
1616
export const StudentComponent: React.FC<Props> = props => {
1717
const { room, log } = props;
1818

19-
const {isAutoScrollEnabled, setIsAutoScrollEnabled, textAreaRef, doAutoScroll} = useAutoScroll();
19+
const {
20+
isAutoScrollEnabled,
21+
setIsAutoScrollEnabled,
22+
textAreaRef,
23+
doAutoScroll,
24+
} = useAutoScroll();
2025

2126
React.useEffect(() => {
2227
doAutoScroll();
2328
}, [log]);
2429

2530
return (
26-
2731
<>
2832
<main className={innerClasses.root}>
29-
<Typography className={innerClasses.sessionName} variant="body1" role="heading">
33+
<Typography
34+
className={innerClasses.sessionName}
35+
variant="body1"
36+
role="heading"
37+
>
3038
Session name: {room ?? ''}
3139
</Typography>
3240
<label className={innerClasses.label} htmlFor="session">
3341
Content
3442
</label>
3543
<TextareaAutosize
44+
role="log"
3645
ref={textAreaRef}
3746
id="session"
3847
rowsMax={30}
3948
rowsMin={30}
4049
className={innerClasses.textarea}
4150
value={log ?? ''}
51+
readOnly={true}
4252
/>
4353
<FormControlLabel
4454
label="Disable AutoScroll"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('SessionComponent unit tests', () => {
1616

1717
render(<SessionComponent {...props} />);
1818

19-
const textArea = screen.getByRole('textbox');
19+
const textArea = screen.getByRole('log');
2020
const sendFullContentButton = screen.getAllByRole('button')[1];
2121

2222
userEvent.type(textArea, 'How are you doing?');
@@ -40,7 +40,7 @@ describe('SessionComponent unit tests', () => {
4040

4141
render(<SessionComponent {...props} />);
4242

43-
const textArea = screen.getByRole('textbox');
43+
const textArea = screen.getByRole('log');
4444
const sendFullContentButton = screen.getAllByRole('button')[1];
4545

4646
userEvent.type(textArea, 'How are you doing?');
@@ -64,7 +64,7 @@ describe('SessionComponent unit tests', () => {
6464

6565
render(<SessionComponent {...props} />);
6666

67-
const textArea = screen.getByRole('textbox');
67+
const textArea = screen.getByRole('log');
6868
const undoButton = screen.getAllByRole('button')[0];
6969

7070
userEvent.type(textArea, 'How are you doing?');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const SessionComponent: React.FC<Props> = props => {
4848
</label>
4949

5050
<TextareaAutosize
51+
role="log"
5152
ref={textAreaRef}
5253
id="session"
5354
rowsMax={20}

0 commit comments

Comments
 (0)