Bug Tracker

Modify

Ticket #6705 (closed bug: patchwelcome)

Opened 4 years ago

Last modified 20 months ago

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:
Blocking: Blocked by:

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

test.html Download (1.1 KB) - added by easyTree 4 years ago.
Demonstrates that focus handler fires twice when triggered using 'focus()'

Change History

Changed 4 years ago by easyTree

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

comment:1 Changed 4 years ago by dmethvin

  • Component changed from unfiled to event

comment:2 Changed 3 years ago by dmethvin

  • Priority set to undecided
  • Status changed from new to open

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

comment:3 Changed 3 years ago by snover

  • Milestone 1.4.3 deleted

Resetting milestone to future.

comment:4 Changed 3 years ago by john

  • Priority changed from undecided to high
  • Blocked by 6593 added
  • Milestone set to 1.next

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

comment:5 Changed 3 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned
  • Blocked by 6593 removed
  • Milestone changed from 1.next to 1.7

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

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

comment:6 Changed 3 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed

comment:7 Changed 3 years ago by dmethvin

  • Status changed from closed to reopened
  • Resolution fixed deleted

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.

comment:8 Changed 3 years ago by dmethvin

  • Status changed from reopened to open
  • Version changed from 1.4.2 to 1.6.4
  • Milestone changed from 1.7 to 1.next

comment:9 Changed 2 years ago by dmethvin

  • Keywords ie6 ie7 added; focus trigger removed

comment:10 Changed 23 months ago by dmethvin

  • Status changed from open to closed
  • Resolution set to patchwelcome

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.

comment:11 Changed 23 months ago by scott.gonzalez

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...

comment:12 Changed 22 months ago by dmethvin

#12094 is a duplicate of this ticket.

comment:13 Changed 20 months ago by anonymous

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

comment:14 Changed 20 months ago by olegku@…

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

comment:15 Changed 20 months ago by dmethvin

@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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.