Popup <input> doesn't loose focus #5706

vkammerer opened this Issue Feb 27, 2013 · 19 comments


None yet

10 participants


Hello JQM community,

After opening a popup including form elements like input and textarea (only types tested so far) and giving the focus to one of these elements, it is impossible to loose focus again, unless your close the popup.

This bug is visible on the current Demo center.

Steps to reproduce:
1 - go to the popup page of the demo center:
2 - Scroll down to the Form section and click the "Sign In" button
3 - Set focus to one of the input fields.
4 - Try to click somewhere else in the popup: You can't loose focus again!

Tested on:

  • Desktop: Windows 7 / Chrome Canary
  • Mobile: Galaxy Note 2 / Android 4.1.2 / Webview (Phonegap)
agcolom commented Feb 27, 2013

@vkammerer I am not experiencing this issue but I have a different setting from yours.

Working fine on:
Desktop: OS X 10.6.8 FF18.0.2, Safari 5.1.7 and Chrome 25.0.1364.99
Mobile: iPod Touch iOS 5.0.1


@agcolom thanks for the reply!

I did more testing and I could reproduce the bug on all environments:

on Galaxy Note 2 / Android 4.1.2:

  • up to date Chrome.
  • Android Stock browser.
  • Webview.

on desktop / Windows 7:

  • Safari 5.1
  • Firefox 18.0
  • Chrome 25.0.1364.97 m

If you first click on an input field and then click somewhere else in the popup (like on the "Please sign in" h3), do you loose the focus on the input?

Moreover, I noticed that if you first open a popup, set focus to one of its fields, close the popup by clicking outside, and then open the same popup again, it will automatically set focus to the input after 1 or 2 seconds.


@agcolom I am only reading now the description of the component : "You can place a form inside a popup. When it opens, focus will be restricted to elements inside the popup."

So it seems that this component is behaving so by design and that this is not a bug.

I'm a bit dubious about this behaviour though, as it can be interesting to place other elements in popups that can be focused.


@agcolom actually, this is a bug:

the description says:
"focus will be restricted to elements inside the popup"

but it doesn't say
"focus cannot be lost inside the popup"

The behaviour I am experiencing in my Android Phonegap app is that the soft keyboard keeps popin after setting focus to a field inside a popup. I am sure this can't be so by design.

agcolom commented Feb 27, 2013

@vkammerer I get what you mean now. Sorry I thought that you could not lose focus on a previously focused input filed inside a a popup. Yes, it seems that the only way to lose focus on an input field inside a popup is to click/tap inside another input field and get that new one into focus. So if this is what you meant, then I can reproduce :-)

@uGoMobi Is that something that we can look at? Outside of popups, tapping/clicking outside of a previously selected (in focus) input field, tapping/clicking outside of that input field will cause it not to be in focus anymore. However, inside the popup, this is not happening. So if you have tapped/clicked inside a form element inside a popup, clicking outside of that form element in the popup will not allow this input field to lose focus (except if you click inside another form element on the popup, but then the problem is just passed to another form element, and so not resolved)


@agcolom thanks! your question to @uGoMobi is exactly what I was trying to explain :-)


@gabrielschulhof - Can you weigh in here? Thanks!

@gabrielschulhof gabrielschulhof added a commit that closed this issue Feb 28, 2013
@gabrielschulhof gabrielschulhof Popup: When focusing on the container, do not bounce focus to an elem…
…ent inside it even if such an element is available. Fixes #5706.

@vkammerer Could you please verify that this fix results in the popup behaviour you desire?

@gabrielschulhof gabrielschulhof added a commit that referenced this issue Feb 28, 2013
@gabrielschulhof gabrielschulhof Popup: When focusing on the container, do not bounce focus to an elem…
…ent inside it even if such an element is available. Fixes #5706.

(cherry picked from commit c605423)

@gabrielschulhof it's all good now, thanks!


I had the same problem on IPhone. Thanks a lot!


Hi, this problem seems to have come up again in 1.4.5. Working okay in 1.3.2.

Platforms - Safari iOS 8.1.2 (iPad) and Chrome 40.0.2214.93 (Win32).Thanks. Daniel.


After further investigation, it looks like this issue did not exist in 1.4.4. This is really annoying especially if the first element inside the popup is a select. Thanks. Daniel.

matpag commented May 11, 2015

i have the same problem with 1.4.5, cant loose focus of input popup without clicking another input field...


Hi Soulcyber, we just ended out using 1.4.4. It may not be the ideal solution and I'm sure it can be worked around but everything else in our application works okay now. Thanks. Daniel.

matpag commented May 12, 2015

Thanks Daniel 👍


Is there a solution for 1.4.5?


I removed ui.focusElement.focus(); and it works fine for me. But is this the right solution?


mkattner, this is at line 10558 in jquery.mobile-1.4.5.js, right?


Muchas gracias si me sirvió.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment