Skip to content

Commit

Permalink
[Autocomplete] Support ChipProps prop (#18917)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWiles authored and oliviertassinari committed Dec 18, 2019
1 parent e40082e commit bf42340
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/pages/api/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| <span class="prop-name">autoHighlight</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the first option is automatically highlighted. |
| <span class="prop-name">autoSelect</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the selected option becomes the value of the input when the Autocomplete loses focus unless the user chooses a different option or changes the character string in the input. |
| <span class="prop-name">blurOnSelect</span> | <span class="prop-type">'mouse'<br>&#124;&nbsp;'touch'<br>&#124;&nbsp;bool</span> | <span class="prop-default">false</span> | Control if the input should be blurred when an option is selected:<br>- `false` the input is not blurred. - `true` the input is always blurred. - `touch` the input is blurred after a touch event. - `mouse` the input is blurred after a mouse event. |
| <span class="prop-name">ChipProps</span> | <span class="prop-type">object</span> | | Props applied to the [`Chip`](/api/chip/) element. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">clearOnEscape</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, clear all values when the user presses escape and the popup is closed. |
| <span class="prop-name">clearText</span> | <span class="prop-type">string</span> | <span class="prop-default">'Clear'</span> | Override the default text for the *clear* icon button.<br>For localization purposes, you can use the provided [translations](/guides/localization/). |
Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export interface AutocompleteProps
AutocompleteClassKey,
'defaultValue' | 'onChange' | 'children'
> {
/**
* Props applied to the [`Chip`](/api/chip/) element.
*/
ChipProps?: object;
/**
* The icon to display in place of the default close icon.
*/
Expand Down
12 changes: 11 additions & 1 deletion packages/material-ui-lab/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
autoHighlight = false,
autoSelect = false,
blurOnSelect = false,
ChipProps,
classes,
className,
clearOnEscape = false,
Expand Down Expand Up @@ -307,7 +308,12 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
startAdornment = renderTags(value, getCustomizedTagProps);
} else {
startAdornment = value.map((option, index) => (
<Chip label={getOptionLabel(option)} size={size} {...getCustomizedTagProps({ index })} />
<Chip
label={getOptionLabel(option)}
size={size}
{...getCustomizedTagProps({ index })}
{...ChipProps}
/>
));
}
}
Expand Down Expand Up @@ -475,6 +481,10 @@ Autocomplete.propTypes = {
* - `mouse` the input is blurred after a mouse event.
*/
blurOnSelect: PropTypes.oneOfType([PropTypes.oneOf(['mouse', 'touch']), PropTypes.bool]),
/**
* Props applied to the [`Chip`](/api/chip/) element.
*/
ChipProps: PropTypes.object,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
Expand Down

0 comments on commit bf42340

Please sign in to comment.