File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Expand file tree Collapse file tree 1 file changed +18
-18
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,15 +89,22 @@ class TagSelect extends React.Component {
96
89
}
97
90
98
91
handleTagRemoveButtonClick ( tag ) {
99
- return ( e ) => {
100
- let { value } = this . props
101
-
92
+ this . removeTagByCallback ( ( value , tag ) => {
102
93
value . splice ( value . indexOf ( tag ) , 1 )
103
- value = _ . uniq ( value )
94
+ } , tag )
95
+ }
104
96
105
- this . value = value
106
- this . props . onChange ( )
107
- }
97
+ removeTagByCallback ( callback , tag = null ) {
98
+ let { value } = this . props
99
+
100
+ value = _ . isArray ( value )
101
+ ? value . slice ( )
102
+ : [ ]
103
+ callback ( value , tag )
104
+ value = _ . uniq ( value )
105
+
106
+ this . value = value
107
+ this . props . onChange ( )
108
108
}
109
109
110
110
render ( ) {
@@ -118,7 +118,7 @@ class TagSelect extends React.Component {
118
118
>
119
119
< span styleName = 'tag-label' > #{ tag } </ span >
120
120
< button styleName = 'tag-removeButton'
121
- onClick = { ( e ) => this . handleTagRemoveButtonClick ( tag ) ( e ) }
121
+ onClick = { ( e ) => this . handleTagRemoveButtonClick ( tag ) }
122
122
>
123
123
< img className = 'tag-removeButton-icon' src = '../resources/icon/icon-x.svg' width = '8px' />
124
124
</ button >
You can’t perform that action at this time.
0 commit comments