Skip to content
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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

Jesion
Copy link

@Jesion Jesion commented Jan 21, 2018

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.

@@ -54,6 +54,7 @@ const factory = (Chip, Input) => {
values: PropTypes.string,
}),
value: PropTypes.any,
submitKeys: PropTypes.array
Copy link
Contributor

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) {
Copy link
Contributor

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.

@@ -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. |
Copy link
Contributor

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/

Copy link
Author

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...

Copy link
Contributor

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.

Copy link
Author

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...

@Jesion Jesion changed the title New prop proposal on Autocomplete component. New prop proposal for the Autocomplete component. Feb 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants