Skip to content

[material-ui][InputBase] onBlur called with undefined event contrary to type definition #45982

Open
@sydneyjodon-wk

Description

@sydneyjodon-wk

Hello 👋

Search keywords

undefined event onBlur

Latest version

  • I have tested the latest version

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/react-zufzmfhc?file=Demo.tsx
  2. Type something in the input
  3. See in the console that the event passed to onBlur is 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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions