From fc83050eddcec2f8134b1c6cfa8816eeca940a26 Mon Sep 17 00:00:00 2001 From: Sagar Bakhtar Date: Wed, 12 Jun 2019 01:20:04 +0530 Subject: [PATCH] AutocompleteArrayInput suggestionLimit prop - test cases and docs update --- docs/Inputs.md | 1 + .../src/input/AutocompleteArrayInput.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/Inputs.md b/docs/Inputs.md index 117748139cc..cc69c591589 100644 --- a/docs/Inputs.md +++ b/docs/Inputs.md @@ -340,6 +340,7 @@ If you need to override the props of the suggestions container (a `Popper` eleme | `optionText` | Optional | string | Function | `name` | Fieldname of record to display in the suggestion item or function which accepts the current record as argument (`(record)=> {string}`) | | `setFilter` | Optional | `Function` | null | A callback to inform the `searchText` has changed and new `choices` can be retrieved based on this `searchText`. Signature `searchText => void`. This function is automatically setup when using `ReferenceInput`. | | `suggestionComponent` | Optional | Function | `({ suggestion, query, isHighlighted, props }) =>
` | Allows to override how the item is rendered. | +| `suggestionLimit` | Optional | Number | null | Limits the numbers of suggestions that are shown in the dropdown list | | `shouldRenderSuggestions` | Optional | Function | `() => true` | A function that returns a `boolean` to determine whether or not suggestions are rendered. Use this when working with large collections of data to improve performance and user experience. This function is passed into the underlying react-autosuggest component. Ex.`(value) => value.trim() > 2` | ## `` and `` diff --git a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js index 96bc931739f..f0299f7d571 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js +++ b/packages/ra-ui-materialui/src/input/AutocompleteArrayInput.spec.js @@ -585,4 +585,18 @@ describe('', () => { wrapper.find('ForwardRef(Popper)').props().disablePortal ).toEqual(true); }); + + it('should limit suggestions when suggestionLimit is passed', () => { + const wrapper = shallow( + + ); + expect(wrapper.state('suggestions')).toHaveLength(1); + }); });