Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export type Props = {
* Callback that is called when the user dismisses the dialog.
*/
onDismiss?: () => void;
/**
* Accessibility label for the overlay. This is read by the screen reader when the user taps outside the dialog.
*/
overlayAccessibilityLabel?: string;
/**
* Determines Whether the dialog is visible.
*/
Expand Down Expand Up @@ -101,6 +105,7 @@ const Dialog = ({
dismissable = true,
dismissableBackButton = dismissable,
onDismiss,
overlayAccessibilityLabel,
visible = false,
style,
theme: themeOverrides,
Expand All @@ -124,6 +129,7 @@ const Dialog = ({
dismissableBackButton={dismissableBackButton}
onDismiss={onDismiss}
visible={visible}
overlayAccessibilityLabel={overlayAccessibilityLabel}
contentContainerStyle={[
{
borderRadius,
Expand Down
16 changes: 16 additions & 0 deletions src/components/__tests__/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,29 @@
it('should render passed children', () => {
const { getByTestId } = render(
<Dialog visible testID="dialog">
<Text>This is simple dialog</Text>

Check failure on line 34 in src/components/__tests__/Dialog.test.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎········visible⏎········overlayAccessibilityLabel="Close·dialog"⏎········testID="dialog"⏎······` with `·visible·overlayAccessibilityLabel="Close·dialog"·testID="dialog"`
</Dialog>
);

expect(getByTestId('dialog')).toHaveTextContent('This is simple dialog');
});

it('should apply overlayAccessibilityLabel to the backdrop', () => {
const { getByTestId } = render(
<Dialog
visible
overlayAccessibilityLabel="Close dialog"
testID="dialog"
>
<Text>This is simple dialog</Text>
</Dialog>
);

expect(getByTestId('dialog-backdrop').props.accessibilityLabel).toBe(
'Close dialog'
);
});

it('should call onDismiss when dismissable', () => {
const onDismiss = jest.fn();
const { getByTestId } = render(
Expand Down
Loading