Skip to content

Commit 7956ba2

Browse files
accessibility changes
1 parent e39ecc3 commit 7956ba2

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

client-react/src/pages/container-app/console/ConsoleDataLoader.styles.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IDialogContentStyleProps, IDialogContentStyles, IDialogFooterStyleProps, IDialogFooterStyles } from '@fluentui/react/lib/Dialog';
22
import { mergeStyleSets } from '@fluentui/react/lib/Styling';
33
import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
4+
import { CSSProperties } from 'react';
45

56
export const consoleStyles = mergeStyleSets({
67
customTextField: {
@@ -13,6 +14,14 @@ export const consoleStyles = mergeStyleSets({
1314
},
1415
});
1516

17+
export const liveRegionStyle: CSSProperties = {
18+
position: 'absolute',
19+
left: '-9999px',
20+
width: '1px',
21+
height: '1px',
22+
overflow: 'hidden',
23+
};
24+
1625
export const dialogFooterStyles = (): IStyleFunctionOrObject<IDialogFooterStyleProps, IDialogFooterStyles> => {
1726
return { actions: { marginTop: '34px' }, actionsRight: { textAlign: 'left' } };
1827
};

client-react/src/pages/container-app/console/ConsoleDataLoader.tsx

+21
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
4444
...(terminalRef.current.terminal.options || {}),
4545
cursorStyle: 'underline',
4646
cursorBlink: true,
47+
screenReaderMode: true,
4748
};
4849

4950
resizeHandler(width, height);
@@ -67,6 +68,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
6768
terminalRef.current.terminal.options = {
6869
...(terminalRef.current.terminal.options || {}),
6970
disableStdin: true,
71+
screenReaderMode: true,
7072
};
7173

7274
resizeHandler(width, height);
@@ -126,6 +128,13 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
126128

127129
const updateConsoleText = (text: string) => {
128130
terminalRef.current?.terminal.write(text);
131+
const liveRegion = document.getElementById('live-region');
132+
if (liveRegion) {
133+
liveRegion.textContent = `${liveRegion.textContent || ''}${text}`;
134+
setTimeout(() => {
135+
liveRegion.textContent = '';
136+
}, 1000); // Clear after 1 second
137+
}
129138
};
130139

131140
const onData = (data: string) => {
@@ -215,6 +224,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
215224
terminalRef.current.terminal.options = {
216225
...(terminalRef.current.terminal.options || {}),
217226
disableStdin: false,
227+
screenReaderMode: true,
218228
};
219229
}
220230
}
@@ -268,6 +278,17 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
268278
return (
269279
<div className={containerAppStyles.divContainer}>
270280
<XTerm ref={terminalRef} onData={onData} onKey={onKey} />
281+
<div
282+
id="live-region"
283+
aria-live="polite"
284+
style={{
285+
position: 'absolute',
286+
left: '-9999px',
287+
width: '1px',
288+
height: '1px',
289+
overflow: 'hidden',
290+
}}
291+
/>
271292
<Dialog hidden={hideDialog} dialogContentProps={dialogContentProps} modalProps={modalProps} forceFocusInsideTrap={false}>
272293
{isDebug ? (
273294
<Text>{t('containerApp_console_debugConsoleDescription')}</Text>

client-react/src/pages/container-app/log-stream/LogStream.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getTerminalDimensions } from '../xtermHelper';
66
import { PortalContext } from '../../../PortalContext';
77
import { containerAppStyles } from '../ContainerApp.styles';
88
import { TextUtilitiesService } from '../../../utils/textUtilities';
9+
import { liveRegionStyle } from '../console/ConsoleDataLoader.styles';
910

1011
export interface LogStreamProps {
1112
resourceId: string;
@@ -18,6 +19,7 @@ const LogStream: React.FC<LogStreamProps> = props => {
1819

1920
const { width, height } = useWindowSize();
2021
const terminalRef = useRef<XTerm>(null);
22+
const liveRegionRef = useRef<HTMLDivElement>(null);
2123
const timeoutRef = useRef<NodeJS.Timeout>();
2224
const xtermReady = useRef(false);
2325

@@ -63,6 +65,16 @@ const LogStream: React.FC<LogStreamProps> = props => {
6365
useEffect(() => {
6466
if (terminalRef.current?.terminal && props.line) {
6567
terminalRef.current?.terminal.writeln(props.line);
68+
69+
if (liveRegionRef.current) {
70+
liveRegionRef.current.textContent = props.line;
71+
72+
setTimeout(() => {
73+
if (liveRegionRef.current) {
74+
liveRegionRef.current.textContent = '';
75+
}
76+
}, 1000); // Clear after 1 second
77+
}
6678
}
6779
}, [props.line]);
6880

@@ -86,6 +98,7 @@ const LogStream: React.FC<LogStreamProps> = props => {
8698

8799
return (
88100
<div className={containerAppStyles.divContainer}>
101+
<div ref={liveRegionRef} aria-live="polite" style={liveRegionStyle} />
89102
<XTerm
90103
options={{
91104
disableStdin: true,

0 commit comments

Comments
 (0)