-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New prop proposal for the Autocomplete component. #1791
base: dev
Are you sure you want to change the base?
Conversation
Added submitKeys prop.
@@ -54,6 +54,7 @@ const factory = (Chip, Input) => { | |||
values: PropTypes.string, | |||
}), | |||
value: PropTypes.any, | |||
submitKeys: PropTypes.array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe PropTypes.arrayOf(PropTypes.number)
?
if (event.which === 13) { | ||
this.selectOrCreateActiveItem(event); | ||
} | ||
if (this.props.submitKeys.includes(event.which) === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to compare to true? includes()
returns boolean already.
components/autocomplete/readme.md
Outdated
@@ -62,6 +62,7 @@ If you want to provide a theme via context, the component key is `RTAutocomplete | |||
| `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), `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. | | |||
| `submitKeys` | `Array` | `[13]` | Array of numbers representing keyboard keys that will trigger active item creation or selection. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be helpful to link to resource where possible values are listed? E.g. https://css-tricks.com/snippets/javascript/javascript-keycodes/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @3af, how about this one: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode?. Anyways, I have implemented the review changes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Jesion, looks good too. Thanks for the changes.
Unfortunatelly I can't merge so let's wait till Javi has time for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No probs @3af. Thanks for reviewing...
Hi! Thanks for putting together this brilliant component set. I would like to propose a new prop on Autocomplete component - 'submitKeys'. It would mean an array of numbers representing keyboard keys that will trigger active item creation or selection.
This would allow programmers to configure which keyboard keys would trigger active item creation or selection. Defaults to 13, so this change is backwards compatible.