Skip to content

[material-ui][Autocomplete] onInputChange called with undefined event contrary to type definition #43899

Open
@sydneyjodon-wk

Description

@sydneyjodon-wk

Steps to reproduce

Link to live example: (required) https://stackblitz.com/edit/react-ouzbqw?file=Demo.tsx

Steps:

  1. Set the onInputChange prop
  2. Check what is passed in for the event param

Current behavior

Hello 👋

I'm noticing that the onInputChange is typed as:

onInputChange?: (
    event: React.SyntheticEvent,
    value: string,
    reason: AutocompleteInputChangeReason,
) => void;

with a non-null event param, but null seems to be coming through for the param on mount. See demo:

onInputChange-null-event

Expected behavior

I'm not sure if onInputChange is supposed to be called on mount or not, but if it is and it's expected that null is an option for event, would it be possible to update the typing of onInputChange to reflect that?

Thanks!

Context

We are trying to use strict null safety

Your environment

See https://stackblitz.com/edit/react-ouzbqw?file=Demo.tsx - also reproduce-able in this docs demo

Search keywords: onInputChange undefined event

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions