Skip to content

Commit

Permalink
Merge pull request #2914 from tiagoschenkel/improve-autocomplete-arra…
Browse files Browse the repository at this point in the history
…y-input

Limit autocomplete height on AutocompleteArrayInput
  • Loading branch information
fzaninotto authored Feb 26, 2019
2 parents 0062aa9 + 9aaf7d3 commit f8683ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/ra-data-json-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default (apiUrl, httpClient = fetchUtils.fetchJson) => {
break;
case GET_MANY: {
const query = {
id: params.ids
id: params.ids,
};
url = `${apiUrl}/${resource}?${stringify(query)}`;
break;
Expand Down
17 changes: 13 additions & 4 deletions packages/ra-ui-materialui/src/input/AutocompleteArrayInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const styles = theme => ({
marginBottom: theme.spacing.unit * 3,
zIndex: 2,
},
suggestionsPaper: {
maxHeight: '50vh',
overflowY: 'auto',
},
suggestion: {
display: 'block',
fontFamily: theme.typography.fontFamily,
Expand Down Expand Up @@ -357,23 +361,28 @@ export class AutocompleteArrayInput extends React.Component {
}
}

renderSuggestionsContainer = options => {
renderSuggestionsContainer = autosuggestOptions => {
const {
containerProps: { className, ...containerProps },
children,
} = options;
} = autosuggestOptions;
const { classes = {} } = this.props;

// Force the Popper component to reposition the popup only when this.inputEl is moved to another location
this.updateAnchorEl();

return (
<Popper
className={className}
open
open={Boolean(children)}
anchorEl={this.anchorEl}
placement="bottom-start"
>
<Paper square {...containerProps}>
<Paper
square
className={classes.suggestionsPaper}
{...containerProps}
>
{children}
</Paper>
</Popper>
Expand Down

0 comments on commit f8683ff

Please sign in to comment.