Closed
Description
-
@testing-library/user-event
version: 12.0.2 -
Testing Framework and version: Jest, whatever version CodeSandbox uses
-
DOM Environment: jsdom, whatever version CodeSandbox uses
Relevant code or config
import Modal from 'react-modal';
function ModalTest() {
return (
<Modal isOpen={true}>
<button>button 1</button>
<button>button 2</button>
</Modal>;
}
it('should allow tabbing inside of a modal', () => {
const { getByText } = render(<ModalTest {...props} />);
const button1 = getByText("button 1");
const button2 = getByText("button 2");
expect(button1).toBeInTheDocument();
expect(button2).toBeInTheDocument();
button1.focus();
expect(button1).toHaveFocus();
userEvent.tab();
// fails right here
expect(button2).toHaveFocus();
});
What you did:
- Render a Modal from react-modal with some tabbable elements
- Try to tab between elements using userEvent.tab()
What happened:
3. The focused element does not change 😢
Reproduction repository:
https://codesandbox.io/s/xenodochial-mestorf-qx6j8?file=/src/__tests__/index.js
Problem description:
Tabbing does not work properly when inside of a react-modal.
Additional notes:
I'm aware the issue could be in the react-modal library, so I made a companion issue over there (clicky). I'm also thinking I could just need more understanding of how the focus trapping is working in react-modal / user-event so I can get them to play together nicely.
Metadata
Metadata
Assignees
Labels
No labels