File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -44,16 +44,9 @@ class TagSelect extends React.Component {
44
44
}
45
45
46
46
removeLastTag ( ) {
47
- let { value } = this . props
48
-
49
- value = _ . isArray ( value )
50
- ? value . slice ( )
51
- : [ ]
52
- value . pop ( )
53
- value = _ . uniq ( value )
54
-
55
- this . value = value
56
- this . props . onChange ( )
47
+ this . removeTagByCallback ( ( value ) => {
48
+ value . pop ( )
49
+ } )
57
50
}
58
51
59
52
reset ( ) {
@@ -96,12 +89,18 @@ class TagSelect extends React.Component {
96
89
}
97
90
98
91
handleTagRemoveButtonClick ( tag ) {
92
+ this . removeTagByCallback ( ( value , tag ) => {
93
+ value . splice ( value . indexOf ( tag ) , 1 )
94
+ } , tag )
95
+ }
96
+
97
+ removeTagByCallback ( callback , tag = null ) {
99
98
let { value } = this . props
100
99
101
100
value = _ . isArray ( value )
102
101
? value . slice ( )
103
102
: [ ]
104
- value . splice ( value . indexOf ( tag ) , 1 )
103
+ callback ( value , tag )
105
104
value = _ . uniq ( value )
106
105
107
106
this . value = value
You can’t perform that action at this time.
0 commit comments