First, thanks for this library - great abstraction.
I just tried to use the userEvent.click() function on a radio button that is implemented as <div role="radio" /> (e.g. @palmerhq/radio-group) and it didn't quite yield the same expected behavior as directly calling fireEvent.click(). I see the click logic currently looks for <input type="radio" /> and calls clickBooleanElement, but this implementation of a radio button falls through to clickElement.
In the actual application, clicking said radio button moves the focus to an input field that becomes enabled when this radio button is selected. If I use fireEvent.click to select the radio button, asserting focus to be on the text input afterwards is successful. But using userEvent.click causes the focus assertion to fail.
The current published version of @testing-library/user-event results in the radio div retaining focus. I locally modified it to check for this type of element and call clickBooleanElement instead, but that doesn't seem to be quite right either. In that version, body ends up with focus.
Thoughts?
First, thanks for this library - great abstraction.
I just tried to use the
userEvent.click()function on a radio button that is implemented as<div role="radio" />(e.g.@palmerhq/radio-group) and it didn't quite yield the same expected behavior as directly callingfireEvent.click(). I see the click logic currently looks for<input type="radio" />and callsclickBooleanElement, but this implementation of a radio button falls through toclickElement.In the actual application, clicking said radio button moves the focus to an input field that becomes enabled when this radio button is selected. If I use
fireEvent.clickto select the radio button, asserting focus to be on the text input afterwards is successful. But usinguserEvent.clickcauses the focus assertion to fail.The current published version of
@testing-library/user-eventresults in the radiodivretaining focus. I locally modified it to check for this type of element and callclickBooleanElementinstead, but that doesn't seem to be quite right either. In that version,bodyends up with focus.Thoughts?