Bug Tracker

Modify

Ticket #7768 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

Focus Event does not get triggered in Safari and Chrome

Reported by: anonymous Owned by:
Priority: undecided Milestone: 1.6
Component: event Version: 1.3.1
Keywords: Cc:
Blocking: Blocked by:

Description

There is a nice demo for this online:  http://pastebin.me/973509bd873d9ef90fa19c961e77fb27

Change History

comment:1 Changed 3 years ago by jitter

  • Component changed from unfiled to event

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case! After checking your report and test case it's unclear why you did report this for version 1.3.1? Anyhow, this isn't a jQuery issue but a browser issue. From  focs() documentation.

This event is implicitly applicable to a limited set of elements

and

The focus is used to determine which element is the first to receive keyboard-related events.

and

In recent browser versions, the event can be extended to include all element types by explicitly setting the element's tabindex property

Also look at e.g.  quirksmode focus table (may not be uptodate) which gives a nice impression on how differently this event is supported across browsers.

In Chrome/Safari certain elements simply don't get the "keyboard focus" when clicking on them, you can see that they are not highlighted and that e.g. hitting ENTER/SPACE doesn't do anything to the e.g button you just clicked. But you can give these elements the focus by using the TAB key and voilà the event is triggered.

This is actually a Webkit bug (bug  #22261) and it isn't clear if they are ever going to fix this or just keeping it like this because that's how Mac/Safari did this the last 8 years.

 test case where you can try out the TAB focus thingy and see that tabIndex makes also the stuff in the 3rd box focusable.

I guess this is a wontfix but leaving it still open so others can share their view on this one.

comment:2 Changed 3 years ago by snover

  • Status changed from new to closed
  • Resolution set to invalid

Technically, certain elements don’t focus when they are clicked on, they just activate. This varies between browsers and operating system HIGs. (For instance, clicking a button in Mac OS never focuses it on *any* browser.) It’s not a bug. Also, the code in jitter’s test case is a bit wrong—tabindex -1 disables focusability; tabindex ≥0 enables it.  revised test case

comment:3 Changed 3 years ago by jitter

Oh well... damn me for just trying to click on them to check if focus works after setting tabIndex. Because that works with -1 too, you just can't "tab" to them.

just to clarify: HIG --> Human interface guidelines

Last edited 3 years ago by jitter (previous) (diff)

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.