0

can you please tell me why focus not going to button or not indicating that focus is on button while using TABS in safari browser.

In chrome it is working fine. the problem is on SAFARI browser.

here is my code https://codesandbox.io/s/charming-paper-k7bg3?file=/src/styles.css

.App {
  font-family: sans-serif;
  text-align: center;
}

/* .js-focus-visible :focus:not(.focus-visible) {
  outline: 0;
} */

button:focus,
a:focus {
  outline-offset: 2px;
  outline-width: 2px !important;
  outline-style: dotted !important;
  outline-color: currentColor;
}

.App button:focus,
.App a:focus {
  outline: none !important;
}
.App button:focus-visible,
.App a:focus-visible {
  outline-offset: 2px;
  outline-width: 2px !important;
  outline-style: dotted !important;
  outline-color: currentColor;
}

.js-focus-visible :focus:not(.focus-visible) {
  outline: none !important;
}

/*
  Optionally: Define a strong focus indicator for keyboard focus.
  If you choose to skip this step then the browser's default focus
  indicator will be displayed instead.
*/
.js-focus-visible .focus-visible:focus-visible {
  outline-offset: 2px;
  outline-width: 2px !important;
  outline-style: dotted !important;
  outline-color: currentColor;
}

Set to reproduce.

  1. Focus to First input field then press TAB two times focus should go to button . In chrome it is going .But is safari It is not going why ?

I have already did below answer not working ?

Martin
  • 5,714
  • 2
  • 21
  • 41
user944513
  • 12,247
  • 49
  • 168
  • 318

2 Answers2

8

Because Mac (and Safari) both default to only allowing you to tab into text boxes and lists.

However there is an accessibility setting to enable Full Keyboard Access.

macOS Ventura

This is under System Settings > Accessibility > Keyboard (under the Motor heading).

ventura-accessibility-keyboard

Older macOS versions

Most likely Catalina or before:

full-keyboard-access-older-macos

Note for posterity that Safari > Settings > Advanced (including in Ventura) has a Press Tab to highlight each item on a webpage, though that is not required to make the button in the provided code sandbox selectable.

safari-settings-advanced-tab

Source: https://www.scottohara.me/blog/2014/10/03/link-tabbing-firefox-osx.html

pzrq
  • 1,626
  • 1
  • 18
  • 24
dave
  • 62,300
  • 5
  • 72
  • 93
  • I did this steps are you able to see `buttons` focus – user944513 Jun 09 '21 at 10:03
  • I have already did above steps .but not highlighing – user944513 Jun 09 '21 at 10:04
  • something wrong in CSS . most important thing is I am not to change this thing `button:focus, a:focus { outline-offset: 2px; outline-width: 2px !important; outline-style: dotted !important; outline-color: currentColor; }` I can override but changed – user944513 Jun 09 '21 at 10:07
0

Safari has not enabled tabindex by default.

See this thread: Safari ignoring tabindex