Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accessibility with targeted :focus-visible focus styles for non-pointer devices #793

Closed
15 tasks
cheton opened this issue Aug 18, 2023 · 0 comments · Fixed by #796
Closed
15 tasks

Comments

@cheton
Copy link
Member

cheton commented Aug 18, 2023

Enhance accessibility with selective :focus-visible focus styles for non-pointer devices:

packages/react

  • Button
  • ButtonGroup
  • ModalCloseButton
  • DrawerCloseButton
  • ToastCloseButton
  • AlertCloseButton
  • TagCloseButton
  • Checkbox
  • Radio
  • Switch
  • Menu
  • Tab
  • Tree
  • Pagination

packages/react-docs

  • Side navigation menu

Reference

https://hidde.blog/focus-visible-more-than-keyboard/

:focus-visible should apply to interactions via keyboard or some other non-pointing device.

Examples

ButtonBase

Change outline: 0 to the following:

sx={{
  ':focus:not(:focus-visible)': {
    outline: 0,
  },
}}

Tab

diff --git a/packages/react/src/tabs/styles.js b/packages/react/src/tabs/styles.js
index 94e04e10a..d0a53505b 100644
--- a/packages/react/src/tabs/styles.js
+++ b/packages/react/src/tabs/styles.js
@@ -135,6 +135,7 @@ const useTabStyle = ({
       _focus: {
         borderColor: getBorderColorStyleWithFallback(focusBorderColor),
         color: getColorStyleWithFallback(focusColor),
+        outline: 0, // Disable the default outline to utilize our custom focus style with a border
       },
       _selected: {
         border: 'none',
@@ -291,6 +292,7 @@ const useTabStyle = ({
         px: '3x',
         py: '2x',
         zIndex: 1,
+        outline: 0, // Disable the default outline to utilize our custom focus style with a border
       },
       _selected: {
         backgroundColor: getBackgroundColorStyleWithFallback(selectedBackgroundColor),
@cheton cheton changed the title Remove outline: 0 from ButtonBase Remove outline: 0 from ButtonBase to improve accessibility Aug 18, 2023
@cheton cheton changed the title Remove outline: 0 from ButtonBase to improve accessibility Enhancing accessibility for the outline behavior Aug 18, 2023
@cheton cheton changed the title Enhancing accessibility for the outline behavior Enhance accessibility for the outline behavior Aug 18, 2023
@cheton cheton changed the title Enhance accessibility for the outline behavior Enhance accessibility for the outline style Aug 18, 2023
@cheton cheton changed the title Enhance accessibility for the outline style Enhance accessibility with selective :focus-visible focus styles for non-pointer devices Aug 28, 2023
@cheton cheton changed the title Enhance accessibility with selective :focus-visible focus styles for non-pointer devices Improve accessibility with targeted :focus-visible focus styles for non-pointer devices Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant