-
Notifications
You must be signed in to change notification settings - Fork 41
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
Removed interim fix for tag field #581
Conversation
11af8d6
to
c8ae45b
Compare
pages/add/form/detail-info-fields.js
Outdated
@@ -80,15 +51,17 @@ let Tags = React.createClass({ | |||
}).filter(suggestion => !!suggestion); | |||
}, | |||
render: function() { | |||
let delimiters = [9,13,32,188]; // keycodes for tab,enter,space,comma |
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.
these are constants, so it's better if, at the top the file rather than inside render()
, we say:
const TAG_DELIMITERS = ['\t', '\r', '\n', ' ', ','].map( v => v.charCodeAt(0) );
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.
hey @Pomax , I found out the value returned from charCodeAt
isn’t necessarily the same as the keycode
returned from keyboard event. Comma is one example - it is 44
from charCodeAt
but its keycode is 188
. I searched it a bit but couldn't find a solution... do you know a way to convert character to keycode? If not I guess what I can do is to move that line from render()
to the top of the file and make it a const
.
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.
Interesting point, I had a look and keyCode
is apparently obsolete. I've filed this over on i-like-robots/react-tags#81 too.
To resolve this rather than charCodeAt(0)
we can use codePointAt(0)
which yields the correct value.
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.
@Pomax ",".codePointAt(0)
returns 44
as well 👀
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.
Yeah okay this is weird. Let's take out "32" for space because spaces in tags should be fine (e.g. "digital literacy"), and move it up as a const DELIMITERD = [...]
and then it's R+
pages/add/form/detail-info-fields.js
Outdated
@@ -80,15 +51,17 @@ let Tags = React.createClass({ | |||
}).filter(suggestion => !!suggestion); | |||
}, | |||
render: function() { | |||
let delimiters = [9,13,32,188]; // keycodes for tab,enter,space,comma |
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.
Yeah okay this is weird. Let's take out "32" for space because spaces in tags should be fine (e.g. "digital literacy"), and move it up as a const DELIMITERD = [...]
and then it's R+
c8ae45b
to
1f9caba
Compare
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.
yarrrrr 🐰
🍻 |
Fixes #568
Note: confirm if we want to push for oneWord tags (no spaces) or multi-word tags (with spaces) are fine