From 3faa5a9d799fdddf1ff975ec9e29e0045e8bd0a5 Mon Sep 17 00:00:00 2001
From: Shivam Kataria <32511112+smartshivkat@users.noreply.github.com>
Date: Thu, 3 Dec 2020 05:26:38 +0530
Subject: [PATCH] [Autocomplete] Improve getOptionSelected description (#23817)
---
docs/pages/api-docs/autocomplete.md | 2 +-
packages/material-ui/src/Autocomplete/Autocomplete.js | 3 ++-
packages/material-ui/src/useAutocomplete/useAutocomplete.d.ts | 3 ++-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/docs/pages/api-docs/autocomplete.md b/docs/pages/api-docs/autocomplete.md
index 34caa37fa284a1..6b7a9d3b697ac6 100644
--- a/docs/pages/api-docs/autocomplete.md
+++ b/docs/pages/api-docs/autocomplete.md
@@ -54,7 +54,7 @@ The `MuiAutocomplete` name can be used for providing [default props](/customizat
| getLimitTagsText | func | (more) => `+${more}` | The label to display when the tags are truncated (`limitTags`).
**Signature:**
`function(more: number) => ReactNode`
*more:* The number of truncated tags. |
| getOptionDisabled | func | | Used to determine the disabled state for a given option.
**Signature:**
`function(option: T) => boolean`
*option:* The option to test. |
| getOptionLabel | func | (option) => option.label ?? option | Used to determine the string value for a given option. It's used to fill the input (and the list box options if `renderOption` is not provided).
**Signature:**
`function(option: T) => string`
|
-| getOptionSelected | func | | Used to determine if an option is selected, considering the current value. Uses strict equality by default.
**Signature:**
`function(option: T, value: T) => boolean`
*option:* The option to test.
*value:* The value to test against. |
+| getOptionSelected | func | | Used to determine if an option is selected, considering the current value(s). Uses strict equality by default. ⚠️ Both arguments need to be handled, an option can only match with one value.
**Signature:**
`function(option: T, value: T) => boolean`
*option:* The option to test.
*value:* The value to test against. |
| groupBy | func | | If provided, the options will be grouped under the returned string. The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
**Signature:**
`function(options: T) => string`
*options:* The options to group. |
| handleHomeEndKeys | bool | !props.freeSolo | If `true`, the component handles the "Home" and "End" keys when the popup is open. It should move focus to the first option and last option, respectively. |
| id | string | | This prop is used to help implement the accessibility logic. If you don't provide this prop. It falls back to a randomly generated id. |
diff --git a/packages/material-ui/src/Autocomplete/Autocomplete.js b/packages/material-ui/src/Autocomplete/Autocomplete.js
index 0146c17cf9444c..0bf12b6f42e05d 100644
--- a/packages/material-ui/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui/src/Autocomplete/Autocomplete.js
@@ -680,8 +680,9 @@ Autocomplete.propTypes = {
*/
getOptionLabel: PropTypes.func,
/**
- * Used to determine if an option is selected, considering the current value.
+ * Used to determine if an option is selected, considering the current value(s).
* Uses strict equality by default.
+ * ⚠️ Both arguments need to be handled, an option can only match with one value.
*
* @param {T} option The option to test.
* @param {T} value The value to test against.
diff --git a/packages/material-ui/src/useAutocomplete/useAutocomplete.d.ts b/packages/material-ui/src/useAutocomplete/useAutocomplete.d.ts
index 0dfea8c7994993..cec10d8e0829d7 100644
--- a/packages/material-ui/src/useAutocomplete/useAutocomplete.d.ts
+++ b/packages/material-ui/src/useAutocomplete/useAutocomplete.d.ts
@@ -133,8 +133,9 @@ export interface UseAutocompleteProps<
*/
getOptionLabel?: (option: T) => string;
/**
- * Used to determine if an option is selected, considering the current value.
+ * Used to determine if an option is selected, considering the current value(s).
* Uses strict equality by default.
+ * ⚠️ Both arguments need to be handled, an option can only match with one value.
*
* @param {T} option The option to test.
* @param {T} value The value to test against.