Skip to content

Inifinite loop when clicking on a select inside a label element #453

Closed
@foxbunny

Description

@foxbunny
  • DOM Testing Library version: 6.12.0
  • node version: 13.7.0
  • npm (or yarn) version: 6.13.6

Relevant code or config:

Component:

export default function App() {
  return (
    <label>
      Select me:
      <select>
        <option value="1">first</option>
      </select>
    </label>
  );
}

Test:

test('click select', function () {
  let { getByRole } = render(<App/>)
  fireEvent.click(getByRole('listbox'))
})

What you did:

Simulated a click on a <select> element that is inside a <label> element.

What happened:

Get Maximum call stack size exceeded.

Reproduction:

https://codesandbox.io/s/eloquent-pike-7uw1h

Problem description:

When clicking a select (or possibly input) element which is inside a label, the code is thrown into an infinite loop, which shouldn't happen.

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions