Skip to content

Commit

Permalink
[Autocomplete] Add forcePopupIcon prop (#18886)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraMarcelaHerreraArriaga authored and oliviertassinari committed Dec 17, 2019
1 parent ab6e802 commit 162515b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/pages/api/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| <span class="prop-name">disablePortal</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | Disable the portal behavior. The children stay within it's parent DOM hierarchy. |
| <span class="prop-name">filterOptions</span> | <span class="prop-type">func</span> | | A filter function that determines the options that are eligible.<br><br>**Signature:**<br>`function(options: undefined, state: object) => undefined`<br>*options:* The options to render.<br>*state:* The state of the component. |
| <span class="prop-name">filterSelectedOptions</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, hide the selected options from the list box. |
| <span class="prop-name">forcePopupIcon</span> | <span class="prop-type">'auto'<br>&#124;&nbsp;bool</span> | <span class="prop-default">'auto'</span> | Force the visibility display of the popup icon. |
| <span class="prop-name">freeSolo</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options. |
| <span class="prop-name">getOptionDisabled</span> | <span class="prop-type">func</span> | | Used to determine the disabled state for a given option. |
| <span class="prop-name">getOptionLabel</span> | <span class="prop-type">func</span> | <span class="prop-default">x => x</span> | 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). |
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 @@ -62,6 +62,10 @@ export interface AutocompleteProps
* The children stay within it's parent DOM hierarchy.
*/
disablePortal?: boolean;
/**
* Force the visibility display of the popup icon.
*/
forcePopupIcon?: true | false | 'auto';
/**
* The component used to render the listbox.
*/
Expand Down
9 changes: 7 additions & 2 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
disablePortal = false,
filterOptions,
filterSelectedOptions = false,
forcePopupIcon = 'auto',
freeSolo = false,
getOptionDisabled,
getOptionLabel = x => x,
Expand Down Expand Up @@ -373,7 +374,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
</IconButton>
)}

{freeSolo ? null : (
{(!freeSolo || forcePopupIcon === true) && forcePopupIcon !== false ? (
<IconButton
{...getPopupIndicatorProps()}
disabled={disabled}
Expand All @@ -385,7 +386,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
>
{popupIcon}
</IconButton>
)}
) : null}
</div>
),
},
Expand Down Expand Up @@ -545,6 +546,10 @@ Autocomplete.propTypes = {
* If `true`, hide the selected options from the list box.
*/
filterSelectedOptions: PropTypes.bool,
/**
* Force the visibility display of the popup icon.
*/
forcePopupIcon: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.bool]),
/**
* If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
*/
Expand Down

0 comments on commit 162515b

Please sign in to comment.