@@ -34,7 +34,6 @@ module.exports = React.createClass( {
34
34
className :'' ,
35
35
listClassName :'' ,
36
36
onClick ( ) {
37
- console . log ( 'onClick should be defined' ) ;
38
37
} ,
39
38
onSelect ( value ) {
40
39
console . log ( 'onItemSelect should be defined' ) ;
@@ -96,14 +95,22 @@ module.exports = React.createClass( {
96
95
} ,
97
96
98
97
handleClick ( event ) {
99
- event . preventDefault ( ) ;
100
- event . stopPropagation ( ) ;
101
- this . setState ( { isOpen :true } ) ;
102
- if ( this . props . onClick ) {
103
- this . props . onClick ( ) ;
98
+ EventUtil . trap ( event ) ;
99
+ if ( ! this . state . isOpen ) {
100
+ this . setState ( { isOpen :true } ) ;
101
+ if ( this . props . onClick ) {
102
+ this . props . onClick ( ) ;
103
+ }
104
+ }
105
+ else {
106
+ this . handleClose ( ) ;
104
107
}
105
108
} ,
106
109
110
+ handleMouseDown ( event ) {
111
+ EventUtil . trapImmediate ( event ) ;
112
+ } ,
113
+
107
114
handleBlur ( e ) {
108
115
this . setState ( { isFocused :false } ) ;
109
116
} ,
@@ -128,10 +135,12 @@ module.exports = React.createClass( {
128
135
event . keyCode === KEYS . DOWN ||
129
136
event . keyCode === KEYS . UP ) {
130
137
EventUtil . trapEvent ( event ) ;
138
+
131
139
this . setState ( {
132
140
isOpen :true ,
133
141
highlightedIndex :0
134
142
} ) ;
143
+
135
144
}
136
145
}
137
146
} ,
@@ -205,7 +214,7 @@ module.exports = React.createClass( {
205
214
let className = this . state . currentSelectedItem ? 'slds-input--bare slds-hide' :'slds-input--bare' ;
206
215
return (
207
216
208
- < div className = { "slds-form-element ignore-react-onclickoutside slds-theme--" + this . props . theme } >
217
+ < div className = { "slds-form-element slds-theme--" + this . props . theme } >
209
218
< div className = { "slds-picklist slds-theme--" + this . props . theme } >
210
219
< form >
211
220
< button
@@ -216,6 +225,7 @@ module.exports = React.createClass( {
216
225
onBlur = { this . handleBlur }
217
226
onFocus = { this . handleFocus }
218
227
onClick = { this . handleClick }
228
+ onMouseDown = { this . handleMouseDown }
219
229
tabIndex = { this . state . isOpen ?- 1 :0 }
220
230
onKeyDown = { this . handleKeyDown } >
221
231
< span className = "slds-truncate" > { this . getPlaceholder ( ) } </ span >
@@ -232,6 +242,7 @@ module.exports = React.createClass( {
232
242
} ,
233
243
234
244
componentDidUpdate ( prevProps , prevState ) {
245
+
235
246
if ( this . state . lastBlurredTimeStamp !== prevState . lastBlurredTimeStamp ) {
236
247
if ( this . state . lastBlurredIndex === this . state . highlightedIndex ) {
237
248
this . handleClose ( ) ;
@@ -254,9 +265,11 @@ module.exports = React.createClass( {
254
265
}
255
266
}
256
267
268
+
257
269
if ( this . props . value !== prevProps . value ) {
258
270
this . handleSelect ( this . getIndexByValue ( this . props . value ) ) ;
259
271
}
272
+
260
273
} ,
261
274
262
275
} ) ;
0 commit comments