Skip to content

Keyboard arrows navigation not causing input[type=radio] to change focus #843

Closed
@mwojslaw

Description

@mwojslaw
  • @testing-library/user-event version: 13.5.0
  • Testing Framework and version: jest - v27.4.7, @testing-library/jest-dom - v5.16.1,
  • DOM Environment: jsdom - v19.0.0

Relevant code or config

it('radio and keyboard navigation', async () => {
  render(
    <>
      <input name="test" aria-label="1" type="radio" />
      <input name="test" aria-label="2" type="radio" />
    </>
  );
  userEvent.tab();
  
  // Here we're fine
  expect(screen.getByLabelText('1')).toHaveFocus();
  
  userEvent.keyboard('{arrowdown}');
  
  // Here we're not
  expect(screen.getByLabelText('2')).toHaveFocus();
});

What you did:

Trigger keyboard navigation on input type radio.

What happened:

  • Focus is not changing accordingly.
  • onchange event is not triggered as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accuracyImproves the accuracy of how behavior is simulatedenhancementNew feature or requestreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions