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

Delimiters and keyCode limitation, with non-English keyboards #87

Closed
ajmas opened this issue Aug 10, 2017 · 4 comments
Closed

Delimiters and keyCode limitation, with non-English keyboards #87

ajmas opened this issue Aug 10, 2017 · 4 comments
Labels

Comments

@ajmas
Copy link
Contributor

ajmas commented Aug 10, 2017

There appears to be a small limitation when using keyCode as delimiter. Using the comma, as example:

   ','.keyCode(0) --> 44
   comma key pressed returns 188

So the solution would appears to be use use delimiters=[ 188 ], but this actually has a limitation if we are targeting a user base where English is not the UI language and the keyboard places the comma elsewhere, such as with the Arabic keyboard. In this scenario the keyCode is that of the 'K' key.

Testing suggest the event.key value is actually more accurate in this case. To allow for the character, on top of the key code, while maintaining backwards compatibility, the simplest approach could be a new property:

   delimterChars=[',']

So the resultant code would be:

if (this.props.delimiters.indexOf(e.keyCode) !== -1 || this.props.delimitersChars.indexOf(e.key)) { ... }

If you think this is an acceptable solution I could create a PR for this?

ajmas added a commit to ajmas/react-tags that referenced this issue Aug 10, 2017
@i-like-robots
Copy link
Owner

Hi @ajmas, thank you for taking the time to work on this. I reckon this addresses the same issue as #84 (might be worth passing your eyes over the thread). This looks to be a simple solution without breaking compatibility (event.key has been discussed in #81, too). I'll give it a test when I get a moment.

@ajmas
Copy link
Contributor Author

ajmas commented Aug 11, 2017

For issue #84 is slightly different, since that would need to depend on the onPaste event, but it could benefit from the delimiterChars array.

@i-like-robots
Copy link
Owner

i-like-robots commented Aug 14, 2017

Yes, sorry - I meant if we could use the same option to tackle both issues. Or even replacing the current keyCode option with an array of characters... though that may get confusing if a user intentionally wishes to type the word Enter or Backspace! To be honest I think the term delimiters makes more sense in the context of your PR than the current usage 🤔

i-like-robots added a commit that referenced this issue Aug 14, 2017
Fixes issue #87 - delimiters on non US keyboards
@i-like-robots
Copy link
Owner

Fixed with #88 and #89 which will be in the 5.5.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants