Skip to content

Commit cd845a5

Browse files
authored
fix: accessibility issues on share query dialog (#3708)
1 parent e7c0ff4 commit cd845a5

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/app/views/common/copy-button/CopyButton.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ export default function CopyButton(props: ICopyButtonProps) {
3131

3232
return (
3333
<>
34+
<div
35+
role="status"
36+
aria-live="assertive"
37+
style={{
38+
position: 'absolute',
39+
left: '-9999px',
40+
width: '1px',
41+
height: '1px',
42+
overflow: 'hidden'
43+
}}
44+
>
45+
{copied && translateMessage('Copied')}
46+
</div>
3447
{props.isIconButton ? (
3548
<Tooltip content={copyLabel} relationship='label'>
3649
<Button
@@ -40,7 +53,7 @@ export default function CopyButton(props: ICopyButtonProps) {
4053
/>
4154
</Tooltip>
4255
) : (
43-
<Button appearance='transparent' onClick={handleCopyClick}>
56+
<Button appearance='primary' onClick={handleCopyClick}>
4457
{copyLabel}
4558
</Button>
4659
)}

src/app/views/common/popups/DialogWrapper.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@ import {
77
DialogTitle,
88
Spinner
99
} from '@fluentui/react-components';
10-
import { Suspense } from 'react';
10+
import { Suspense, useEffect, useRef } from 'react';
1111

1212
import { WrapperProps } from './popups.types';
1313

1414
export function DialogWrapper(props: WrapperProps) {
1515
const { isOpen, dismissPopup, Component, popupsProps, closePopup } = props;
1616
const { settings: { title, subtitle } } = popupsProps;
17+
const focusableRef = useRef<HTMLDivElement>(null);
18+
19+
useEffect(() => {
20+
if (isOpen && focusableRef.current) {
21+
focusableRef.current.focus();
22+
}
23+
}, [isOpen]);
1724

1825
return (
19-
<Dialog modalType='non-modal' open={isOpen} onOpenChange={(_, data) => !data.open && dismissPopup()}>
26+
<Dialog modalType='modal' aria-modal='true' open={isOpen} onOpenChange={(_, data) => !data.open && dismissPopup()}>
2027
<DialogSurface>
2128
<DialogBody>
2229
{title && <DialogTitle>{title.toString()}</DialogTitle>}

src/app/views/query-runner/query-input/share-query/ShareQuery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ShareQuery: React.FC<PopupsComponent<null>> = (props) => {
5959

6060
<DialogActions>
6161
<CopyButton handleOnClick={handleCopy} isIconButton={false} />
62-
<Button appearance="secondary" onClick={() => props.dismissPopup()}>
62+
<Button appearance='secondary' onClick={() => props.dismissPopup()}>
6363
{translateMessage('Close')}
6464
</Button>
6565
</DialogActions>

0 commit comments

Comments
 (0)