@@ -15,6 +15,12 @@ import {
15
15
import allowClearTest from './shared/allowClearTest' ;
16
16
import throwOptionValue from './shared/throwOptionValue' ;
17
17
18
+ async function delay ( timeout = 0 ) {
19
+ return new Promise ( resolve => {
20
+ setTimeout ( resolve , timeout ) ;
21
+ } ) ;
22
+ }
23
+
18
24
describe ( 'Select.Combobox' , ( ) => {
19
25
injectRunAllTimers ( jest ) ;
20
26
@@ -147,7 +153,7 @@ describe('Select.Combobox', () => {
147
153
148
154
public render ( ) {
149
155
const options = this . state . data . map ( item => (
150
- < Option key = { item . key } > { item . label } </ Option >
156
+ < Option value = { item . key } > { item . label } </ Option >
151
157
) ) ;
152
158
return (
153
159
< Select
@@ -188,7 +194,7 @@ describe('Select.Combobox', () => {
188
194
189
195
public render ( ) {
190
196
const options = this . state . data . map ( item => (
191
- < Option key = { item . key } > { item . label } </ Option >
197
+ < Option value = { item . key } > { item . label } </ Option >
192
198
) ) ;
193
199
return (
194
200
< Select
@@ -300,7 +306,7 @@ describe('Select.Combobox', () => {
300
306
return (
301
307
< Select mode = "combobox" onChange = { this . updateOptions } >
302
308
{ this . state . options . map ( opt => (
303
- < Option key = { opt } > { opt } </ Option >
309
+ < Option value = { opt } > { opt } </ Option >
304
310
) ) }
305
311
</ Select >
306
312
) ;
@@ -369,4 +375,28 @@ describe('Select.Combobox', () => {
369
375
370
376
expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toEqual ( '' ) ;
371
377
} ) ;
378
+
379
+ it ( 'should keep close after blur' , async ( ) => {
380
+ const wrapper = mount (
381
+ < Select mode = "combobox" notFoundContent = { null } >
382
+ < Option value = "One" > One</ Option >
383
+ </ Select > ,
384
+ ) ;
385
+
386
+ toggleOpen ( wrapper ) ;
387
+ expectOpen ( wrapper ) ;
388
+
389
+ // Click again should not close popup
390
+ for ( let i = 0 ; i < 10 ; i += 1 ) {
391
+ wrapper . find ( 'input' ) . simulate ( 'mouseDown' ) ;
392
+ wrapper . update ( ) ;
393
+ expectOpen ( wrapper ) ;
394
+ }
395
+
396
+ wrapper . find ( 'input' ) . simulate ( 'blur' ) ;
397
+ await delay ( 100 ) ;
398
+
399
+ wrapper . update ( ) ;
400
+ expectOpen ( wrapper , false ) ;
401
+ } ) ;
372
402
} ) ;
0 commit comments