@@ -224,9 +224,11 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
224224 } ,
225225
226226 _bindToggleHandlers : function ( ) {
227- var self = this , delay ,
227+ var self = this ,
228228 o = self . options ,
229- $el = self . element ;
229+ $el = self . element ,
230+ delayShow , delayHide ,
231+ isVisible = true ;
230232
231233 // tap toggle
232234 $el . closest ( ".ui-page" )
@@ -243,16 +245,24 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
243245 //and issue #4410 Footer navbar moves up when clicking on a textbox in an Android environment
244246 if ( screen . width < 1025 && $ ( e . target ) . is ( o . hideDuringFocus ) && ! $ ( e . target ) . closest ( ".ui-header-fixed, .ui-footer-fixed" ) . length ) {
245247 //Fix for issue #4724 Moving through form in Mobile Safari with "Next" and "Previous" system
246- //controls causes fixed position, tap-toggle false Header to reveal itself
247- if ( e . type === "focusout" && ! self . _visible ) {
248+ //controls causes fixed position, tap-toggle false Header to reveal itself
249+ // isVisible instead of self._visible because the focusin and focusout events fire twice at the same time
250+ // Also use a delay for hiding the toolbars because on Android native browser focusin is direclty followed
251+ // by a focusout when a native selects opens and the other way around when it closes.
252+ if ( e . type === "focusout" && ! isVisible ) {
253+ isVisible = true ;
248254 //wait for the stack to unwind and see if we have jumped to another input
249- delay = setTimeout ( function ( ) {
255+ clearTimeout ( delayHide ) ;
256+ delayShow = setTimeout ( function ( ) {
250257 self . show ( ) ;
251258 } , 0 ) ;
252- } else if ( e . type === "focusin" && self . _visible ) {
259+ } else if ( e . type === "focusin" && ! ! isVisible ) {
253260 //if we have jumped to another input clear the time out to cancel the show.
254- clearTimeout ( delay ) ;
255- self . hide ( ) ;
261+ clearTimeout ( delayShow ) ;
262+ isVisible = false ;
263+ delayHide = setTimeout ( function ( ) {
264+ self . hide ( ) ;
265+ } , 0 ) ;
256266 }
257267 }
258268 } ) ;
0 commit comments