Skip to content

chore(modal-dialog-primitive): upgrade reach dialog #1464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2021
Merged
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 .changeset/giant-beers-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/animation-library': patch
'@twilio-paste/core': patch
---

Bumped the version of React-Spring to 9.1.2 in order to fix a TS issue.
6 changes: 6 additions & 0 deletions .changeset/tender-icons-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@twilio-paste/modal-dialog-primitive': patch
'@twilio-paste/core': patch
---

Bumped the version of Reach/Dialog to 0.15.0
27 changes: 20 additions & 7 deletions packages/paste-core/components/modal/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import {useUID} from '@twilio-paste/uid-library';
import {render} from 'react-dom';
import {render as testRender, fireEvent, cleanup} from '@testing-library/react';
import {render as testRender, fireEvent} from '@testing-library/react';
import {Theme} from '@twilio-paste/theme';
import {Button} from '@twilio-paste/button';
import {Box} from '@twilio-paste/box';
Expand Down Expand Up @@ -102,41 +102,54 @@ describe('Modal', () => {
const {getByTestId} = testRender(<MockModal />);
expect(getByTestId('modal').getAttribute('role')).toEqual('dialog');
expect(getByTestId('modal').getAttribute('aria-modal')).toEqual('true');
cleanup();
});

it('should be labelled by the correct heading', () => {
const {getByTestId} = testRender(<MockModal />);
expect(getByTestId('modal').getAttribute('aria-labelledby')).toEqual(
getByTestId('modal-heading').getAttribute('id')
);
cleanup();
});

it('should be be able to take arbitrary html attributes on the container', () => {
const {getByTestId} = testRender(<MockModal />);
expect(getByTestId('modal').getAttribute('aria-busy')).toEqual('true');
expect(getByTestId('modal').getAttribute('id')).toEqual('a-new-id');
cleanup();
});

it('should render with focusable elements in the modal content', () => {
const {getByTestId} = testRender(
<MockModal>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<button type="button">Button</button>
<input type="text" defaultValue="test" aria-label="test" />
</MockModal>
);
expect(getByTestId('modal')).toBeDefined();
});

it('should focus on the first focusable element in the modal, the close button', () => {
const {getByTestId} = testRender(<MockModal />);
expect(document.activeElement).toEqual(getByTestId('modal-header').querySelector('button'));
cleanup();
});

it('should focus on the element provided as the initialFocus element in the modal', () => {
const {getByTestId} = testRender(<MockInitalFocusModal />);
expect(document.activeElement).toEqual(getByTestId('modal-body').querySelector('input'));
cleanup();
});

it('should call the onDismiss function when the close button is clicked', () => {
const {getByTestId} = testRender(<MockModal />);
fireEvent.click(getByTestId('modal-header').querySelector('button') as HTMLButtonElement);
expect(handleCloseMock).toHaveBeenCalled();
cleanup();
});

it('Should have no accessibility violations', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/paste-core/components/modal/src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import * as PropTypes from 'prop-types';
import {styled, css} from '@twilio-paste/styling-library';
import {useTransition, animated} from '@twilio-paste/animation-library';
import {safelySpreadBoxProps} from '@twilio-paste/box';
import {pasteBaseStyles} from '@twilio-paste/theme';
import {ModalDialogPrimitiveOverlay, ModalDialogPrimitiveContent} from '@twilio-paste/modal-dialog-primitive';
import {ModalContext} from './ModalContext';
Expand Down Expand Up @@ -130,8 +131,7 @@ const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
>
<ModalDialogContent
aria-labelledby={ariaLabelledby}
{...props}
className={null}
{...safelySpreadBoxProps(props)}
ref={ref}
style={styles}
size={size}
Expand Down
2 changes: 1 addition & 1 deletion packages/paste-core/primitives/modal-dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"tsc": "tsc"
},
"dependencies": {
"@reach/dialog": "0.11.2"
"@reach/dialog": "0.15.0"
},
"peerDependencies": {
"react": "^16.8.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/paste-libraries/animation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"tsc": "tsc"
},
"dependencies": {
"@react-spring/shared": "9.0.0-rc.3",
"@react-spring/web": "9.0.0-rc.3"
"@react-spring/shared": "9.1.2",
"@react-spring/web": "9.1.2"
},
"peerDependencies": {
"react": "^16.8.6",
Expand Down
Loading