@@ -216,7 +216,7 @@ const AutoComplete = React.createClass({
216216 onUpdateInput : ( ) => { } ,
217217 onNewRequest : ( ) => { } ,
218218 searchText : '' ,
219- menuCloseDelay : 200 ,
219+ menuCloseDelay : 300 ,
220220 targetOrigin : {
221221 vertical : 'top' ,
222222 horizontal : 'left' ,
@@ -254,15 +254,9 @@ const AutoComplete = React.createClass({
254254
255255 componentWillUnmount ( ) {
256256 clearTimeout ( this . timerTouchTapCloseId ) ;
257- clearTimeout ( this . timerBlurCloseId ) ;
258257 } ,
259258
260- componentClickAway ( ) {
261- this . close ( ) ;
262- } ,
263-
264- timerTouchTapCloseId : undefined ,
265- timerBlurCloseId : undefined ,
259+ timerTouchTapCloseId : null ,
266260
267261 close ( ) {
268262 this . setState ( {
@@ -271,6 +265,14 @@ const AutoComplete = React.createClass({
271265 } ) ;
272266 } ,
273267
268+ handleRequestClose ( ) {
269+ // Only take into account the Popover clickAway when we are
270+ // not focusing the TextField.
271+ if ( ! this . state . focusTextField ) {
272+ this . close ( ) ;
273+ }
274+ } ,
275+
274276 setValue ( textValue ) {
275277 warning ( false , 'setValue() is deprecated, use the searchText property.' ) ;
276278
@@ -285,6 +287,11 @@ const AutoComplete = React.createClass({
285287 return this . state . searchText ;
286288 } ,
287289
290+ handleMouseDown ( event ) {
291+ // Keep the TextField focused
292+ event . preventDefault ( ) ;
293+ } ,
294+
288295 handleItemTouchTap ( event , child ) {
289296 const dataSource = this . props . dataSource ;
290297 let chosenRequest ;
@@ -304,12 +311,12 @@ const AutoComplete = React.createClass({
304311
305312 this . props . onNewRequest ( chosenRequest , index ) ;
306313
307- clearTimeout ( this . timerBlurCloseId ) ;
308314 this . timerTouchTapCloseId = setTimeout ( ( ) => {
309315 this . setState ( {
310316 searchText : searchText ,
311317 } ) ;
312318 this . close ( ) ;
319+ this . timerTouchTapCloseId = null ;
313320 } , this . props . menuCloseDelay ) ;
314321 } ,
315322
@@ -360,12 +367,8 @@ const AutoComplete = React.createClass({
360367 } ,
361368
362369 handleBlur ( event ) {
363- // Run asynchronously to wait for a potential handleItemTouchTap() call.
364- // The blur event occurs first on a click device and after on a touch device.
365- if ( this . state . focusTextField ) {
366- this . timerBlurCloseId = setTimeout ( ( ) => {
367- this . close ( ) ;
368- } , 0 ) ;
370+ if ( this . state . focusTextField && this . timerTouchTapCloseId === null ) {
371+ this . close ( ) ;
369372 }
370373
371374 if ( this . props . onBlur ) {
@@ -464,6 +467,7 @@ const AutoComplete = React.createClass({
464467 onEscKeyDown = { this . close }
465468 initiallyKeyboardFocused = { false }
466469 onItemTouchTap = { this . handleItemTouchTap }
470+ onMouseDown = { this . handleMouseDown }
467471 listStyle = { Object . assign ( styles . list , listStyle ) }
468472 style = { Object . assign ( styles . menu , menuStyle ) }
469473 >
@@ -526,7 +530,7 @@ const AutoComplete = React.createClass({
526530 open = { open }
527531 anchorEl = { anchorEl }
528532 useLayerForClickAway = { false }
529- onRequestClose = { this . close }
533+ onRequestClose = { this . handleRequestClose }
530534 animated = { animated }
531535 >
532536 { menu }
0 commit comments