-
Notifications
You must be signed in to change notification settings - Fork 726
Closed
Description
This is quite similar to testing-library/react-testing-library#532 and testing-library/react-testing-library#544. But different from those, it is happening with a present and valid value for the type attribute of the input element.
@testing-library/react
version: 9.4.0react
version: 16.9.3node
version: 8.17.0npm
(oryarn
) version: npm 6.13.4material-ui/core
3.9.2
Relevant code or config:
<TextField
type="date"
value={this.state.date}
onFocus={() => {console.log('FOCUS')}}
onChange={() => {console.log('CHANGE')}}
InputProps={{inputProps: {'data-testid': 'filter-date-input'}}}
/>
test.only('input date', async () => {
const {getByTestId} = renderForTesting(<SomeComponent/>);
const input = getByTestId('filter-date-input');
console.log(`type: ` + input.getAttribute('type')); // prints type: date
fireEvent.focus(input);
fireEvent.change(input, { target: { value: '12/05/2020' } });
// some code here waiting on result of onChange
});
What you did:
Trying to fire onChange of a component.
What happened:
BLUR is seen in the output (onBlur called).
CHANGE is not seen in the output (onChange not called).
If I change the type on TextField to "text", both events are fired.
However "date" is a valid type for inputs, and I can see that the input element material-ui creates has this from the log statement and some HTML from Chrome:
<input aria-invalid="false" class="MuiInputBase-input-198 MuiInput-input-183 MuiInputBase-inputType-201 MuiInput-inputType-186 MuiInputBase-inputMarginDense-199 MuiInput-inputMarginDense-184 MuiInputBase-inputAdornedStart-203" type="date" data-testid="filter-date-input" value="">
Reproduction:
Problem description:
Suggested solution:
Metadata
Metadata
Assignees
Labels
No labels