Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12648 closed bug (fixed)

Can not correctly detect focus for DIVs with contenteditable in Chrome and Safari

Reported by: Marvin Owned by:
Priority: high Milestone: 1.8.3
Component: selector Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:


Related to ticket #12492: The bug there was about textareas and input fields in Chrome and Safari and was fixed in 1.8.2.

The very same bug still (jQuery 1.8.2) exists in div elements with contenteditable="true":


is always FALSE in Chrome and Safari.

Example: http://jsfiddle.net/YzagR/3/

Change History (7)

comment:1 Changed 11 years ago by dmethvin

#12646 is a duplicate of this ticket.

comment:2 Changed 11 years ago by dmethvin

Updated fiddle: http://jsfiddle.net/YzagR/5/

If you click into the div, note the values. Then click to another tab and click back, note that the values are different. This seems like an inconsistency with the :focus selector in qSA and mS.

comment:3 Changed 11 years ago by Marvin

dmethvin, you are right: qSA and mS behave inconsistently. It depends if you switch focus by clicking on elements *within* the same page or if you click on another page/application and then click on an element. But I think this is another issue, and probably an issue for the Webkit developers, because it does not occur on Firefox or Opera.

My issue is only about how to detect if a specific div has focus when the user clicks around on the same webpage. This is important for many web applications, especially for my current project, a rich text email writer webapp.

is(':active') works on all platform in 1.8.2, but not is(':focus').

I analized the problem on different browsers (mobile and desktop). The focus tests should always return "true", but they do not:

<DIV ce>jQ 1.8.2jQ 1.7.2
Firefox 15falsetruetruetruetruetrue
Opera 12falsetrue-truetrue-

<textarea>jQ 1.8.2jQ 1.7.2
Firefox 15truetruetruetruetruetrue
Opera 12truetrue-truetrue-

Conclusion: focus detection with is(':focus') works only well for textareas on all platforms, but not for divs. qSA and mS are not reliable, either.

Question: Is there a chance jQ can fix is(':focus') for DIVs as it has been done for textareas already?

Remark: I hope very much jQ can found a workaround over the inconsistencies between different browsers and implement a reliable is(':focus') behaviour. It is easier to use a jQ update than to wait for Apple to implement an updated Mobile Safari in iOS 6...

p.s. I would be grateful for any workaround...

comment:4 Changed 11 years ago by Marvin

Here is a jsFiddle example I used for testing:


comment:5 Changed 11 years ago by mikesherov

#12713 is a duplicate of this ticket.

comment:6 in reply to:  5 Changed 11 years ago by pascal.wacker@…

Replying to mikesherov:

#12713 is a duplicate of this ticket.

Hi all (:

Sorry for the duplicated tic

I use a little workaround that you find here: http://pastie.org/5043656

Hope this helps you a little


comment:7 Changed 11 years ago by Timmy Willison

Component: unfiledselector
Milestone: None1.8.3
Priority: undecidedhigh
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.