Skip to main content

Bug Tracker

Side navigation

#6705 closed bug (patchwelcome)

Opened June 22, 2010 10:08AM UTC

Closed June 02, 2012 03:08PM UTC

Last modified August 30, 2012 01:42PM UTC

focus() causes focus event to be handled twice in IE8

Reported by: easyTree Owned by: dmethvin
Priority: high Milestone: 1.next
Component: event Version: 1.6.4
Keywords: ie6 ie7 ie8 Cc:
Blocked by: Blocking:
Description

Attaching a handler for the focus event to an input/text then focusing the field using focus() causes the handler to run twice in IE8. In firefox, behavior is as expected

Attached is a a simple html page demonstrating the bug.

Attachments (1)
  • test.html (1.1 KB) - added by easyTree June 22, 2010 10:11AM UTC.

    Demonstrates that focus handler fires twice when triggered using 'focus()'

Change History (15)

Changed June 23, 2010 02:22AM UTC by dmethvin comment:1

component: unfiledevent

Changed November 11, 2010 02:40AM UTC by dmethvin comment:2

priority: → undecided
status: newopen

Not sure what can be done to fix it, but this was also observed by Scott González.

Changed November 12, 2010 02:39AM UTC by snover comment:3

milestone: 1.4.3

Resetting milestone to future.

Changed April 17, 2011 08:13PM UTC by john comment:4

blockedby: → 6593
milestone: → 1.next
priority: undecidedhigh

I think this is actually very similar to #6593. We're working to try and fix the problem over there for the change event.

Changed September 08, 2011 05:33PM UTC by dmethvin comment:5

blockedby: 6593
milestone: 1.next1.7
owner: → dmethvin
status: openassigned

Confirmed: http://jsfiddle.net/dmethvin/gsJyE/

This appears to be fixed in my 1.7 branch, I'll confirm once it lands.

Changed September 20, 2011 12:42PM UTC by dmethvin comment:6

resolution: → fixed
status: assignedclosed

Changed October 11, 2011 03:17AM UTC by dmethvin comment:7

resolution: fixed
status: closedreopened

I had to back out this fix, among other things it was causing focus/blur handlers to not run in cases where the focus/blur method didn't feel they should be fired -- for example, if the element was already focused.

Changed October 11, 2011 03:17AM UTC by dmethvin comment:8

milestone: 1.71.next
status: reopenedopen
version: 1.4.21.6.4

Changed March 03, 2012 09:50PM UTC by dmethvin comment:9

keywords: focus trigger ie8ie6 ie7 ie8

Changed June 02, 2012 03:08PM UTC by dmethvin comment:10

resolution: → patchwelcome
status: openclosed

I can't think of acceptable solutions that can be implemented at the core level. At present we can either choose to execute the focus handlers either 0-or-1 times (my abandoned patch above) or 1-or-2 times (the current behavior) depending on circumstances, and ensuring that they are run at *least* once seems better than having them not run at all in some cases.

Changed June 02, 2012 03:13PM UTC by scottgonzalez comment:11

FWIW, I've talked to Microsoft about this and they don't have an explanation as to why they handle focus asynchronously. They're going to look into making it synchronous for web compat, but that won't happen until after IE10 ships...

Changed July 17, 2012 02:44PM UTC by dmethvin comment:12

#12094 is a duplicate of this ticket.

Changed August 22, 2012 11:43PM UTC by anonymous comment:13

I had this problem in IE. I used preventDefault() and it stopped the double click for my situation.

Changed August 30, 2012 01:40PM UTC by olegku@gmail.com comment:14

Hi, we solved this problem using standard focus method of dom element instead of jquery method.

Changed August 30, 2012 01:42PM UTC by dmethvin comment:15

@olegku, yes that will sort of work, but note that it will not fire the focus event handlers at all if the element is already focused.