[material-ui][InputBase] onBlur called with undefined event contrary to type definition
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Hello 👋
Search keywords
undefined event onBlur
Latest version
- I have tested the latest version
Steps to reproduce
Steps:
- Open this link to live example: https://stackblitz.com/edit/react-zufzmfhc?file=Demo.tsx
- Type something in the input
- See in the console that the event passed to
onBluris undefined if the InputBase is disabled
Current behavior
InputBase is calling onBlur with an undefined event in certain cases, but the type definition for onBlur does not have a nullable event:
/**
* Callback fired when the `input` is blurred.
*
* Notice that the first argument (event) might be undefined.
*/
onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
Even though there is a comment, undefined is not an option for the events.
Expected behavior
I would have expected the behavior of the onBlur to match the type definition and no undefined event to be passed in. Would it be possible to either update the type definition to include undefined or update the onBlur call to pass in an event for InputBase?
Context
We are running with strict null safety and this is causing an issue.
Your environment
See sandbox: https://stackblitz.com/edit/react-zufzmfhc?file=Demo.tsx
Thank you!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/mui-material/src/InputBase/InputBase.js at the linked onBlur call and compare it with the onBlur declaration in packages/mui-material/src/InputBase/InputBase.d.ts. Reproduce the disabled-input case using the linked StackBlitz example, then verify that the runtime behavior and type definition agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100