@@ -108,9 +108,9 @@ class TimePicker extends React.PureComponent {
108108 timeChanged : false 
109109 } ; 
110110
111+  this . onBlur  =  this . onBlur . bind ( this ) ; 
111112 this . onFocus  =  this . onFocus . bind ( this ) ; 
112113 this . timeData  =  this . timeData . bind ( this ) ; 
113-  this . onClearFocus  =  this . onClearFocus . bind ( this ) ; 
114114 this . handleTimeChange  =  this . handleTimeChange . bind ( this ) ; 
115115 this . handleHourChange  =  this . handleHourChange . bind ( this ) ; 
116116 this . handleMinuteChange  =  this . handleMinuteChange . bind ( this ) ; 
@@ -132,11 +132,23 @@ class TimePicker extends React.PureComponent {
132132 } 
133133
134134 onFocus ( )  { 
135-  this . setState ( { 
136-  focused : true 
137-  } ) ; 
135+  const  {  focused }  =  this . state ; 
136+  if  ( ! focused )  { 
137+  this . onFocusChange ( ! focused ) ; 
138+  } 
139+  } 
140+ 
141+  onBlur ( )  { 
142+  const  {  focused }  =  this . state ; 
143+  if  ( focused )  { 
144+  this . onFocusChange ( ! focused ) ; 
145+  } 
146+  } 
147+ 
148+  onFocusChange ( focused )  { 
149+  this . setState ( {  focused } ) ; 
138150 const  {  onFocusChange }  =  this . props ; 
139-  onFocusChange  &&  onFocusChange ( true ) ; 
151+  onFocusChange  &&  onFocusChange ( focused ) ; 
140152 } 
141153
142154 timeData ( timeChanged )  { 
@@ -224,10 +236,6 @@ class TimePicker extends React.PureComponent {
224236 return  m  &&  ! ! ( m . match ( / ^ a m | p m / i) )  ? localMessages [ m . toLowerCase ( ) ]  : m ; 
225237 } 
226238
227-  onClearFocus ( )  { 
228-  this . setState ( {  focused : false  } ) ; 
229-  } 
230- 
231239 onTimeChanged ( timeChanged )  { 
232240 this . setState ( {  timeChanged } ) ; 
233241 } 
@@ -271,7 +279,7 @@ class TimePicker extends React.PureComponent {
271279 handleHourAndMinuteChange ( time )  { 
272280 this . onTimeChanged ( true ) ; 
273281 const  {  onTimeChange,  autoClose }  =  this . props ; 
274-  if  ( autoClose )  this . onClearFocus ( ) ; 
282+  if  ( autoClose )  this . onBlur ( ) ; 
275283 return  onTimeChange  &&  onTimeChange ( time ) ; 
276284 } 
277285
@@ -313,7 +321,7 @@ class TimePicker extends React.PureComponent {
313321 showTimezone = { showTimezone } 
314322 phrases = { this . languageData } 
315323 colorPalette = { colorPalette } 
316-  clearFocus = { this . onClearFocus } 
324+  clearFocus = { this . onBlur } 
317325 timeMode = { parseInt ( timeMode ,  10 ) } 
318326 onTimezoneChange = { onTimezoneChange } 
319327 minuteStep = { parseInt ( minuteStep ,  10 ) } 
@@ -366,7 +374,7 @@ class TimePicker extends React.PureComponent {
366374 ) } 
367375 < OutsideClickHandler 
368376 focused = { focused } 
369-  onOutsideClick = { this . onClearFocus } 
377+  onOutsideClick = { this . onBlur } 
370378 closeOnOutsideClick = { closeOnOutsideClick } 
371379 > 
372380 { this . renderDialPlate ( ) } 
0 commit comments