Bug 199671 - Change of default behavior of tab to focus on form elements
Summary: Change of default behavior of tab to focus on form elements
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 12
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-10 09:21 PDT by Pier Bover
Modified: 2023-06-28 07:02 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pier Bover 2019-07-10 09:21:27 PDT
By default Webkit does not focus on checkboxes/radio/buttons when pressing tab unless a user setting is enabled. This means that by default the tabindex attribute is ignored on certain elements. This seems to go against the typical behavior of sequential focus navigation.

It seems strange that only these specific elements are ignored. For example, it is possible to specify tabindex on a div and pressing tab will focus on it. Is there really more value in being able to focus on a div than a checkbox?

While I understand this unique behavior is historical in Safari, and that it is possible to use alt+tab to focus on any element, shouldn't there be a way for developers to allow focusing on any element when using the universal default keyboard navigation shortcut (tab)? For example, the default behavior could be kept intact unless tabindex was specified in the checkbox.
Comment 1 Tim Horton 2019-07-10 13:54:26 PDT
I think you want the somewhat-questionably-named "tabFocusesLinks" bit in WKPreferences, which will make links and form controls focusable.
Comment 2 Pier Bover 2019-07-10 13:55:54 PDT
That works for WKWebView but not for regular websites.
Comment 3 Tim Horton 2019-07-10 13:57:46 PDT
(In reply to Pier Bover from comment #2)
> That works for WKWebView but not for regular websites.

For websites, it's up to the user (Preferences->Advanced->"Press Tab to highlight each item on a webpage")
Comment 4 Tim Horton 2019-07-10 13:58:12 PDT
If this request is to change the default in Safari, that should be filed at bugreport.apple.com, not here.
Comment 5 Pier Bover 2019-07-10 14:01:30 PDT
Tim, did you read my first comment?
Comment 6 Pier Bover 2019-07-10 14:02:44 PDT
Also, I posted here after Brady Eidson suggested it to me.
Comment 7 Tim Horton 2019-07-10 14:03:02 PDT
I did, but I don't understand your actual request. Is it for *web-facing* API to switch the default for a particular page?
Comment 8 Tim Horton 2019-07-10 14:03:45 PDT
("developers" is an overloaded term on this forum :D)
Comment 9 Tim Horton 2019-07-10 14:06:14 PDT
Ah, I see, the last sentence is important.
Comment 10 Alexey Proskuryakov 2019-07-10 14:11:19 PDT
Seems like the request is to make form controls focusable when they have tabindex. Is that correct?

I'm super suspicious of letting webpages be inconsistent in this regard, that seems like inconsistency would result in poor user experience. On the other hand, I never noticed a problem with divs - not sure if that's because very few pages regrettably modify the behavior for those, or because it's actually an OK thing to do.
Comment 11 Pier Bover 2019-07-10 18:41:20 PDT
(In reply to Alexey Proskuryakov from comment #10)
> Seems like the request is to make form controls focusable when they have
> tabindex. Is that correct?

Yes, that's the idea.

> I'm super suspicious of letting webpages be inconsistent in this regard,
> that seems like inconsistency would result in poor user experience.

On the other hand Safari not focusing on all form elements is the exception compared to other browsers.
Comment 12 Marius S 2023-06-28 07:02:50 PDT
The option "Press Tab to highlight each item on a webpage" should be enabled by default. I think this is important from an accessibility point of view. 

"... A keyboard user typically uses the Tab key to navigate through interactive elements on a web page—links, buttons, fields for inputting text, etc..."

See https://webaim.org/techniques/keyboard/ for details.