Skip to content

[material-ui][Autocomplete] onHighlightChange called when listbox opens without any option being highlighted #43213

Closed
@sydneyjodon-wk

Description

@sydneyjodon-wk

Steps to reproduce

Link to live example: https://stackblitz.com/edit/react-d4b5ls?file=Demo.tsx

Steps:

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

Current behavior

Hello 👋

I'm noticing that the onHighlightChange is typed as:

onHighlightChange?: (
    event: React.SyntheticEvent,
    option: Value | null,
    reason: AutocompleteHighlightChangeReason,
) => void;

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

autocomplete-undefined-event

Expected behavior

Would it be possible to change the typing of the prop to reflect the values that are being passed to event?

- event: React.SyntheticEvent,
+ event: React.SyntheticEvent | undefined,

This seems like it would be consistent with some other onHighlightChange props.

Context

We are trying to use strict null safety

Your environment

See codesandbox link

Search keywords: onHighlightChange, undefined event

Metadata

Metadata

Assignees

Labels

bug 🐛Something doesn't workcomponent: autocompleteThis is the name of the generic UI component, not the React module!package: material-uiSpecific to @mui/material

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions