In the renderOption prop, the second parameter's key, inputValue, is always sent as undefined.
In the renderOption prop, the second parameter's key, inputValue, should be the text the user entered in the input field.
https://codesandbox.io/s/material-demo-8q8zf?fontsize=14
Steps:
inputValue is always undefined.I'm trying to implement the Highlights behaviour described in the documentation: https://material-ui.com/components/autocomplete/#highlights.
| Tech | Version |
| ----------- | ------- |
| Material-UI/core | v4.6.0 |
| Material-UI/lab | v4.0.0-alpha.30 |
| React | v16.11.0 |
| Browser | Chrome (v77.0.3865.90) |
@raducanb Oops, thank you for the report. It's a leftover from the extraction of the core logic in useAutocomplete. What do you think of this diff?
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
index 4160b0152..ad1503a2d 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
@@ -163,6 +163,7 @@ export default function useAutocomplete(
getListboxProps: () => {};
getOptionProps: ({ option, index }: { option: any; index: number }) => {};
id: string;
+ inputValue: string;
value: any;
dirty: boolean;
popupOpen: boolean;
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index 72d7c84c3..396f5bb1a 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -731,6 +731,7 @@ export default function useAutocomplete(props) {
};
},
id,
+ inputValue,
value,
dirty,
popupOpen,
Do you want to work on a pull request? Thanks.
Sorry, I just saw the message. Thank you for the fast response and for the fix @AbdallahElroby & @oliviertassinari !