Open Bug 759922 Opened 13 years ago Updated 9 months ago

Tabindex cannot be applied to <img> tags on Mac

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

12 Branch
x86
macOS
defect

Tracking

()

Webcompat Priority P3
Tracking Status
firefox67 --- wontfix
firefox68 --- wontfix
firefox69 --- wontfix
firefox70 --- wontfix
firefox71 --- fix-optional
firefox72 --- fix-optional

People

(Reporter: sahunt, Unassigned)

References

Details

(Keywords: regression)

Attachments

(2 files, 2 obsolete files)

Attached file FirefoxTab.zip (obsolete) —
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0 Build ID: 20120420145725 Steps to reproduce: Applying a tabindex to an <img> will not give the object focus. Bug was encountered using jQuery to create an interactive file which causes an action to execute on focus for an <img>. Works in all browsers except Firefox 12 for Max. Actual results: 1. Create a new HTML file 2. Link an image in the body using <img> tags. 3. Apply a tabindex value of 1 to the image. 4. Open in Chrome and tab. Notice how the image gains focus. 5. Open in Firefox 12 for Mac and tab. Notice how tabbing skips over the <img> Expected results: <img> tags should be able to gain focus and have same behaviour as Firefox 12 for PC.
Priority: -- → P3
Attachment #628505 - Attachment is obsolete: true
Attachment #747019 - Attachment mime type: text/plain → text/html
This is not a regression it's present since FF 4.0
I'm guessing this isn't going to get fixed anytime soon then. For those looking for a workaround - http://i.imgur.com/xgPIirF.jpg
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Core & HTML
Ever confirmed: true
Product: Firefox → Core
See Also: → 810591
On Mac, there is a system preference that controls whether things like images can be tabbed to; by default they cannot. But I agree that an explicit tabindex should probably override that...
Component: DOM: Core & HTML → Keyboard: Navigation
The reason why tabindex on <img> not working seems a typo. https://dxr.mozilla.org/mozilla-central/source/dom/html/HTMLImageElement.cpp#486-489 > if (aTabIndex) { > // Can be in tab order if tabindex >=0 and form controls are tabbable. > *aTabIndex = (sTabFocusModel & eTabFocus_formElementsMask)? tabIndex : -1; > } HTMLImageElement tries to use tabindex though sTabFocusModel & eTabFocus_formElementsMask is always false on macOS by default. Because sTabFocusModel is 1 by default on macOS while eTabFocus_formElementsMask is 2. https://dxr.mozilla.org/mozilla-central/source/widget/cocoa/nsLookAndFeel.mm#430 https://dxr.mozilla.org/mozilla-central/source/dom/base/nsIContent.h#1027 I think we should just use nsGenericHTMLElement::IsHTMLFocusable except image map handling (I couldn't figure out why <img> is considered a form control).
(In reply to Boris Zbarsky [:bz] from comment #6) > On Mac, there is a system preference that controls whether things like > images can be tabbed to; by default they cannot. > > But I agree that an explicit tabindex should probably override that... Yes, Safari includes <img>, but not <input type=image>, that has a tabindex in the tabbing order. The latter is only included when the system pref is set (and then tabindex isn't needed). We should probably follow that behavior since tabindex on other form controls doesn't make them tab-able. <object type="image/png" tabindex=1 ...> isn't included at all in the tabbing order in Safari, whether the system pref is set or not. That seems odd to me; I think it should behave as <img>. So, it looks like we need to fix both <img> and <input type=image>, but not <object type="image/png">.
> We should probably follow that behavior since tabindex on other form > controls doesn't make them tab-able. In bug 437296, we included <input type="image"> (and other form controls) in the tabbing order regardless of the system settings. I think that we need to change <img> at this moment and bug 1036966 is more suitable place for other elements.
Comment on attachment 8790015 [details] Bug 759922 - make tabindex work on <img> elements on mac I don't have OSX device at hand right now to test this stuff. But, doesn't the patch change how mouse click is handled. What do other browsers do in that case?
Attachment #8790015 - Flags: review?(bugs) → review?(enndeakin)
Attached file Testcase
> What do other browsers do in that case? The div[tabindex], img[tabindex] and img[contenteditable] are tabbable in Safari ("Press Tab to highlight each item on a webpage" is unchecked) and Chrome.
And how do they react to mouse click? Does focus get moved to <img>?
Component: Keyboard: Navigation → User events and focus handling
Webcompat Priority: --- → ?

I should have given context when I flipped the web Compatibility priority for this one. We didn't have any reported webcompat issues related to this one. But I flipped it when I was searching for issues related to tabindex with regards to Bug 1586727 Comment 8 which is also about the sequence of tabbed elements and the difference in between chromium and firefox. So I thought if we fix the other one, while we are in there, better to fix this one too. It seemed like a low hanging fruit.

See Also: → 1586727

Bugbug thinks this bug is a regression, but please revert this change in case of error.

Keywords: regression
Webcompat Priority: ? → P3

(In reply to Karl Dubost💡 :karlcow from comment #15)

I should have given context when I flipped the web Compatibility priority for this one.

Thank you for prioritizing this bug. However, it seems that this bug has not been reproduced. I can move focus to img[tabindex] by pressing tab key on macOS:

Name: Firefox
Version: 84.0a1
Build ID: 20201103213933
Distribution ID:
Update Channel: nightly
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko/20100101 Firefox/84.0
OS: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
Multiprocess Windows: 1/1
Fission Windows: 1/1 Enabled by experiment
Remote Processes: 14
Enterprise Policies: Inactive
Google Location Service Key: Found
Google Safebrowsing Key: Found
Mozilla Location Service Key: Found
Safe Mode: false

It is helpful if you could re-check this bug.

Original testcase: https://bug759922.bmoattachments.org/attachment.cgi?id=747019

Comment on attachment 8790015 [details]
Bug 759922 - make tabindex work on <img> elements on mac

Make old patch obsolete

Attachment #8790015 - Attachment is obsolete: true
Attachment #8790015 - Flags: review?(enndeakin)
Severity: normal → S3
See Also: → 595000
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: