[Input][material-ui] Input and InputBase incorrectly assumed to possibly use <textarea> when not using multiline={true} #39322
Labels
component: text field
This is the name of the generic UI component, not the React module!
typescript
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/kv9phv?file=/src/App.tsx
Steps:
<Input>
or<InputBase>
component with nomultiline
prop so that it definitely renders as an<input>
HTML element and not as a<textarea>
HTML elementtype="file"
or something similar that has specific related properties inHTMLInputElement
onChange
HTMLInputElement
such ase.target.files
Current behavior 😯
TypeScript reports an error because said property does not exit on
HTMLTextAreaElement
Expected behavior 🤔
Unless using
multiline={true}
, the component renders as an HTMLInputElement. TypeScript should recognize it and allow accessing element properties that do not exist on HTMLTextAreaElement.Context 🔦
I'm implementing a simple file picker and I'm forced to use an unsafe type casting or a redundant runtime check (
target instanceof HTMLInputElement
) to make TypeScript happy.Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: