Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit c8ae45b

Browse files
committed
Fixes #568 - removed interim delimiter fix for tag field
1 parent edd7aed commit c8ae45b

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"react-ga": "^2.1.2",
8787
"react-helmet": "^5.0.3",
8888
"react-router": "^3.0.0",
89-
"react-tag-autocomplete": "^5.3.0",
89+
"react-tag-autocomplete": "^5.4.0",
9090
"shx": "^0.2.1",
9191
"superagent": "^3.3.0",
9292
"url": "^0.11.0",

pages/add/form/detail-info-fields.js

+3-30
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,6 @@ let Tags = React.createClass({
2222
.catch((reason) => {
2323
console.error(reason);
2424
});
25-
26-
this.shimTagDelimiter();
27-
},
28-
shimTagDelimiter: function() {
29-
// The ReactTags component for some reason does not
30-
// do tag seperation on anything except "enter" which is
31-
// not an intuitive key when you're on a single-line input.
32-
// We are adding a hack here to force delimiting on comma.
33-
// Ideally, this hack can be taken out again after
34-
// https://github.com/i-like-robots/react-tags/issues/76 is addressed.
35-
try {
36-
const reactTags = this.reactTags;
37-
const trueInput = reactTags.input.input;
38-
const forceKey = reactTags.handleKeyDown.bind(reactTags);
39-
40-
trueInput.addEventListener("keyup", evt => {
41-
// did we type a comma?
42-
const key = evt.key;
43-
if (key === ',') {
44-
// remove the comma and type an enter instead
45-
const { query, selectedIndex } = reactTags.state;
46-
reactTags.state.query = query.substring(0, query.length-1);
47-
forceKey({ keyCode: 13, preventDefault: ()=>{} });
48-
}
49-
});
50-
51-
} catch (e) {
52-
console.warning("Could not set up comma-delimiting for tags");
53-
}
5425
},
5526
updateTags: function(tags) {
5627
this.setState({ tags }, () => {
@@ -80,15 +51,17 @@ let Tags = React.createClass({
8051
}).filter(suggestion => !!suggestion);
8152
},
8253
render: function() {
54+
let delimiters = [9,13,32,188]; // keycodes for tab,enter,space,comma
8355

8456
return <ReactTags
8557
ref={e => this.reactTags = e}
8658
tags={this.state.tags}
8759
suggestions={this.getFilteredSuggestions()}
8860
allowNew={true}
61+
autofocus={false}
62+
delimiters={delimiters}
8963
handleDelete={(...args) => this.handleDelete(...args) }
9064
handleAddition={(...args) => this.handleAddition(...args) }
91-
autofocus={false}
9265
classNames={{
9366
root: `react-tags form-control d-flex flex-column flex-sm-row`,
9467
selectedTag: `selected-tag btn btn-sm mr-sm-2 my-1`,

0 commit comments

Comments
 (0)