Add suggestionMatch option to disable filtering (#1122)

old
Václav Chalupa 2017-01-18 08:33:30 +01:00 committed by Javi Velasco
parent 65f812009a
commit d3fe9f9868
2 changed files with 5 additions and 3 deletions

View File

@ -38,7 +38,7 @@ const factory = (Chip, Input) => {
showSelectedWhenNotInSource: PropTypes.bool,
showSuggestionsWhenValueIsSet: PropTypes.bool,
source: PropTypes.any,
suggestionMatch: PropTypes.oneOf(['start', 'anywhere', 'word']),
suggestionMatch: PropTypes.oneOf(['disabled', 'start', 'anywhere', 'word']),
theme: PropTypes.shape({
active: PropTypes.string,
autocomplete: PropTypes.string,
@ -239,7 +239,9 @@ const factory = (Chip, Input) => {
matches (value, query) {
const { suggestionMatch } = this.props;
if (suggestionMatch === 'start') {
if (suggestionMatch === 'disabled') {
return true;
} else if (suggestionMatch === 'start') {
return value.startsWith(query);
} else if (suggestionMatch === 'anywhere') {
return value.includes(query);

View File

@ -59,7 +59,7 @@ If you want to provide a theme via context, the component key is `RTAutocomplete
| `selectedPosition` | `String` | `above` | Determines if the selected list is shown above or below input. It can be `above`, `below` or `none`. |
| `showSelectedWhenNotInSource` | `Bool` | `false` | Determines if the selected list is shown if the `value` keys don't exist in the source. Only works if passing the `value` prop as an Object. |
| `showSuggestionsWhenValueIsSet` | `Bool` | `false` | If true, the list of suggestions will not be filtered when a value is selected, until the query is modified. |
| `suggestionMatch` | `String` | `start` | Determines how suggestions are supplied. It can be `start` (query matches the start of a suggestion), `anywhere` (query matches anywhere inside the suggestion), or `word` (query matches the start of a word in the suggestion). |
| `suggestionMatch` | `String` | `start` | Determines how suggestions are supplied. It can be `start` (query matches the start of a suggestion), `anywhere` (query matches anywhere inside the suggestion), `word` (query matches the start of a word in the suggestion) or `disabled` (disable filtering of provided source, all items are shown). |
| `value` | `String`, `Array` or `Object` | | Value or array of values currently selected component. |
Additional properties will be passed to the Input Component so you can use `hint`, `name` ... etc.