From b4bb5ad2240ee505e9ad2aca644444d65a09d960 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 3 Mar 2020 16:53:10 +0100 Subject: [PATCH] [Autocomplete] Update onChange API --- docs/pages/api/autocomplete.md | 2 +- packages/material-ui-lab/src/Autocomplete/Autocomplete.js | 1 + .../material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts | 2 ++ packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/pages/api/autocomplete.md b/docs/pages/api/autocomplete.md index 6730d1cb37b905..b6536464eb6278 100644 --- a/docs/pages/api/autocomplete.md +++ b/docs/pages/api/autocomplete.md @@ -58,7 +58,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi | loadingText | node | 'Loading…' | Text to display when in a loading state.
For localization purposes, you can use the provided [translations](/guides/localization/). | | multiple | bool | false | If `true`, `value` must be an array and the menu will support multiple selections. | | noOptionsText | node | 'No options' | Text to display when there are no options.
For localization purposes, you can use the provided [translations](/guides/localization/). | -| onChange | func | | Callback fired when the value changes.

**Signature:**
`function(event: object, value: T) => void`
*event:* The event source of the callback.
*value:* null | +| onChange | func | | Callback fired when the value changes.

**Signature:**
`function(event: object, value: T, reason: string) => void`
*event:* The event source of the callback.
*value:* null
*reason:* One of "create-option", "select-option", "remove-option", "blur" or "clear". | | onClose | func | | Callback fired when the popup requests to be closed. Use in controlled mode (see open).

**Signature:**
`function(event: object) => void`
*event:* The event source of the callback. | | onInputChange | func | | Callback fired when the input value changes.

**Signature:**
`function(event: object, value: string, reason: string) => void`
*event:* The event source of the callback.
*value:* The new value of the text input.
*reason:* Can be: `"input"` (user input), `"reset"` (programmatic change), `"clear"`. | | onOpen | func | | Callback fired when the popup requests to be opened. Use in controlled mode (see open).

**Signature:**
`function(event: object) => void`
*event:* The event source of the callback. | diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js index 612b04d28fac4c..181cd75978d298 100644 --- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js +++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js @@ -660,6 +660,7 @@ Autocomplete.propTypes = { * * @param {object} event The event source of the callback. * @param {T} value + * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear". */ onChange: PropTypes.func, /** diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts index 0b6eb4ece2d54f..12068959eb9c48 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts @@ -190,6 +190,7 @@ export interface UseAutocompleteMultipleProps extends UseAutocompleteCommonPr * * @param {object} event The event source of the callback. * @param {T[]} value + * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear". */ onChange?: ( event: React.ChangeEvent<{}>, @@ -220,6 +221,7 @@ export interface UseAutocompleteSingleProps extends UseAutocompleteCommonProp * * @param {object} event The event source of the callback. * @param {T} value + * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear". */ onChange?: ( event: React.ChangeEvent<{}>, diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js index 2af0e8c49eac37..4add5ab725c98a 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js @@ -1057,7 +1057,7 @@ useAutocomplete.propTypes = { * * @param {object} event The event source of the callback * @param {any} value - * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear" + * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear". */ onChange: PropTypes.func, /**