@@ -3,6 +3,8 @@ import ReactTags from 'react-tag-autocomplete';
3
3
import validator from './validator' ;
4
4
import Service from '../../../js/service' ;
5
5
6
+ const DELIMITERS = [ 9 , 13 , 188 ] ; // keycodes for tab,enter,comma
7
+
6
8
let Tags = React . createClass ( {
7
9
getInitialState ( ) {
8
10
return {
@@ -22,35 +24,6 @@ let Tags = React.createClass({
22
24
. catch ( ( reason ) => {
23
25
console . error ( reason ) ;
24
26
} ) ;
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
- }
54
27
} ,
55
28
updateTags : function ( tags ) {
56
29
this . setState ( { tags } , ( ) => {
@@ -80,15 +53,15 @@ let Tags = React.createClass({
80
53
} ) . filter ( suggestion => ! ! suggestion ) ;
81
54
} ,
82
55
render : function ( ) {
83
-
84
56
return < ReactTags
85
57
ref = { e => this . reactTags = e }
86
58
tags = { this . state . tags }
87
59
suggestions = { this . getFilteredSuggestions ( ) }
88
60
allowNew = { true }
61
+ autofocus = { false }
62
+ delimiters = { DELIMITERS }
89
63
handleDelete = { ( ...args ) => this . handleDelete ( ...args ) }
90
64
handleAddition = { ( ...args ) => this . handleAddition ( ...args ) }
91
- autofocus = { false }
92
65
classNames = { {
93
66
root : `react-tags form-control d-flex flex-column flex-sm-row` ,
94
67
selectedTag : `selected-tag btn btn-sm mr-sm-2 my-1` ,
0 commit comments