Skip to content

Commit

Permalink
Add new props to accept custom titles for Autocomplete buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanloo authored and oliviertassinari committed Nov 11, 2019
1 parent 3d393bf commit ca46117
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/pages/api/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| <span class="prop-name">renderGroup</span> | <span class="prop-type">func</span> | | Render the group.<br><br>**Signature:**<br>`function(option: any) => ReactNode`<br>*option:* The group to render. |
| <span class="prop-name required">renderInput&nbsp;*</span> | <span class="prop-type">func</span> | | Render the input.<br><br>**Signature:**<br>`function(params: object) => ReactNode`<br>*params:* null |
| <span class="prop-name">renderOption</span> | <span class="prop-type">func</span> | | Render the option, use `getOptionLabel` by default.<br><br>**Signature:**<br>`function(option: any, state: object) => ReactNode`<br>*option:* The option to render.<br>*state:* The state of the component. |
<<<<<<< HEAD
| <span class="prop-name">renderTags</span> | <span class="prop-type">func</span> | | Render the selected value.<br><br>**Signature:**<br>`function(value: any, getTagProps: function) => ReactNode`<br>*value:* The `value` provided to the component.<br>*getTagProps:* A tag props getter. |
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The value of the autocomplete. |
=======
| <span class="prop-name">renderTags</span> | <span class="prop-type">func</span> | | Render the selected value.<br><br>**Signature:**<br>`function(value: any) => ReactNode`<br>*value:* The `value` provided to the component. |
| <span class="prop-name">titles</span> | <span class="prop-type">{ clearPopup: string, closePopup: string, openPopup: string }</span> | <span class="prop-default">{ openPopup: 'Open popup', closePopup: 'Close popup', clearPopup: 'Clear',}</span> | Titles to display when hovering the arrow or clear buttons. |
| <span class="prop-name">value</span> | <span class="prop-type">any</span> | | The input value. |
>>>>>>> Add new props to accept custom titles for Autocomplete buttons
The `ref` is forwarded to the root element.

Expand Down
8 changes: 8 additions & 0 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ export interface AutocompleteProps
* @returns {ReactNode}
*/
renderTags?: (value: any, getTagProps: GetTagProps) => React.ReactNode;
/**
* Titles to display when hovering the arrow or clear buttons.
*/
titles?: {
openPopup: string;
closePopup: string;
clearPopup: string;
};
}

export type AutocompleteClassKey =
Expand Down
17 changes: 17 additions & 0 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
renderInput,
renderOption: renderOptionProp,
renderTags,
titles = {
openPopup: 'Open popup',
closePopup: 'Close popup',
clearPopup: 'Clear',
},
value: valueProp,
...other
} = props;
Expand Down Expand Up @@ -592,7 +597,19 @@ Autocomplete.propTypes = {
*/
renderTags: PropTypes.func,
/**
<<<<<<< HEAD
* The value of the autocomplete.
=======
* Titles to display when hovering the arrow or clear buttons.
*/
titles: PropTypes.shape({
clearPopup: PropTypes.string.isRequired,
closePopup: PropTypes.string.isRequired,
openPopup: PropTypes.string.isRequired,
}),
/**
* The input value.
>>>>>>> Add new props to accept custom titles for Autocomplete buttons
*/
value: PropTypes.any,
};
Expand Down

0 comments on commit ca46117

Please sign in to comment.