Is there a way for me to input text into the TextField input within the MUI datepicker using react-testing-library's user-event
? I've noticed that there is a mask applied to the input.
I attempted to use userEvent.type(inputEl, '1')
and userEvent.keyboard('1')
, but the input remained empty in both cases.
My current theory is that a rerender might be causing my updates to be replaced by the empty state of a higher order component, especially since the date format mask is being applied to the input.
The example in the documentation is working as intended, so it seems like my issue is specific to the MUI datepicker.
A simplified version of the component (and test) can be found in this sandbox.
Below is the rendered HTML snippet showing that I'm targeting the input element with a data-testid
which does not seem to be working:
screen.getByTestId('date-selector-text-field').outerHTML:
<input
aria-invalid="false"
placeholder="dd / mm / yyyy"
readonly=""
type="text"
aria-readonly="true"
aria-label="Choose date"
data-testid="date-selector-text-field"
class="MuiOutlinedInput-input MuiInputBase-input css-1t8l2tu-MuiInputBase-input-MuiOutlinedInput-input"
value=""
aria-describedby="mui-1-helper-text"
id="mui-1"
>