Skip to content

Commit

Permalink
accessibility changes
Browse files Browse the repository at this point in the history
  • Loading branch information
StewartMckenzie committed Jan 24, 2025
1 parent e39ecc3 commit 7956ba2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IDialogContentStyleProps, IDialogContentStyles, IDialogFooterStyleProps, IDialogFooterStyles } from '@fluentui/react/lib/Dialog';
import { mergeStyleSets } from '@fluentui/react/lib/Styling';
import { IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';
import { CSSProperties } from 'react';

export const consoleStyles = mergeStyleSets({
customTextField: {
Expand All @@ -13,6 +14,14 @@ export const consoleStyles = mergeStyleSets({
},
});

export const liveRegionStyle: CSSProperties = {
position: 'absolute',
left: '-9999px',
width: '1px',
height: '1px',
overflow: 'hidden',
};

export const dialogFooterStyles = (): IStyleFunctionOrObject<IDialogFooterStyleProps, IDialogFooterStyles> => {
return { actions: { marginTop: '34px' }, actionsRight: { textAlign: 'left' } };
};
Expand Down
21 changes: 21 additions & 0 deletions client-react/src/pages/container-app/console/ConsoleDataLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
...(terminalRef.current.terminal.options || {}),
cursorStyle: 'underline',
cursorBlink: true,
screenReaderMode: true,
};

resizeHandler(width, height);
Expand All @@ -67,6 +68,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
terminalRef.current.terminal.options = {
...(terminalRef.current.terminal.options || {}),
disableStdin: true,
screenReaderMode: true,
};

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

const updateConsoleText = (text: string) => {
terminalRef.current?.terminal.write(text);
const liveRegion = document.getElementById('live-region');
if (liveRegion) {
liveRegion.textContent = `${liveRegion.textContent || ''}${text}`;
setTimeout(() => {
liveRegion.textContent = '';
}, 1000); // Clear after 1 second
}
};

const onData = (data: string) => {
Expand Down Expand Up @@ -215,6 +224,7 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
terminalRef.current.terminal.options = {
...(terminalRef.current.terminal.options || {}),
disableStdin: false,
screenReaderMode: true,
};
}
}
Expand Down Expand Up @@ -268,6 +278,17 @@ const ConsoleDataLoader: React.FC<ConsoleDataLoaderProps> = props => {
return (
<div className={containerAppStyles.divContainer}>
<XTerm ref={terminalRef} onData={onData} onKey={onKey} />
<div
id="live-region"
aria-live="polite"
style={{
position: 'absolute',
left: '-9999px',
width: '1px',
height: '1px',
overflow: 'hidden',
}}
/>
<Dialog hidden={hideDialog} dialogContentProps={dialogContentProps} modalProps={modalProps} forceFocusInsideTrap={false}>
{isDebug ? (
<Text>{t('containerApp_console_debugConsoleDescription')}</Text>
Expand Down
13 changes: 13 additions & 0 deletions client-react/src/pages/container-app/log-stream/LogStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getTerminalDimensions } from '../xtermHelper';
import { PortalContext } from '../../../PortalContext';
import { containerAppStyles } from '../ContainerApp.styles';
import { TextUtilitiesService } from '../../../utils/textUtilities';
import { liveRegionStyle } from '../console/ConsoleDataLoader.styles';

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

const { width, height } = useWindowSize();
const terminalRef = useRef<XTerm>(null);
const liveRegionRef = useRef<HTMLDivElement>(null);
const timeoutRef = useRef<NodeJS.Timeout>();
const xtermReady = useRef(false);

Expand Down Expand Up @@ -63,6 +65,16 @@ const LogStream: React.FC<LogStreamProps> = props => {
useEffect(() => {
if (terminalRef.current?.terminal && props.line) {
terminalRef.current?.terminal.writeln(props.line);

if (liveRegionRef.current) {
liveRegionRef.current.textContent = props.line;

setTimeout(() => {
if (liveRegionRef.current) {
liveRegionRef.current.textContent = '';
}
}, 1000); // Clear after 1 second
}
}
}, [props.line]);

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

return (
<div className={containerAppStyles.divContainer}>
<div ref={liveRegionRef} aria-live="polite" style={liveRegionStyle} />
<XTerm
options={{
disableStdin: true,
Expand Down

0 comments on commit 7956ba2

Please sign in to comment.