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

Fix focus visibility in theme settings #244

Closed
maxatdetroit opened this issue Jul 16, 2024 · 2 comments · Fixed by #245
Closed

Fix focus visibility in theme settings #244

maxatdetroit opened this issue Jul 16, 2024 · 2 comments · Fixed by #245
Assignees
Labels
a11y Digital accessibility. bug Something isn't working

Comments

@maxatdetroit
Copy link
Member

maxatdetroit commented Jul 16, 2024

The Problem

When using tab to focus light elements on a dark background (as someone might due using a keyboard to navigate a site), the focus visibility of elements is non-apparent.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://cityofdetroit.github.io/COD-Design-System/?path=/story/components-organisms-navbar--offcanvas-responsive
  2. Use 'Tab' key to navigate the menu links
  3. Observe that the links 'Home', 'Link' and button 'Dropdown' do not have a box around them while focused

Screenshots

2024-07-16.11-29-30.mp4

Expected Behavior

The links and buttons should have some high contrast visual indicator that they are focused using the keyboard:

2024-07-16.11-28-47.mp4

This behavior was demo by editing the stylesheets like the below, however this is just a reference to understand how the focus styles are computed from the theme. See the next section for a more robust fix for this issue by updating the theme.

/* Inline #3 | https://cityofdetroit.github.io/COD-Design-System/iframe.html?viewMode=story&id=components-organisms-navbar--offcanvas-responsive */

.btn:focus-visible {
  /* box-shadow: var(--bs-btn-focus-box-shadow); */
  /* box-shadow: 0; */
  /* box-shadow: 0 aliceblue; */
  /* box-shadow: 0 0; */
  /* box-shadow: 0 0 aliceblue; */
  /* box-shadow: 0 0 0; */
  /* box-shadow: 0 0 0 aliceblue; */
  /* box-shadow: 0 0 0 .aliceblue; */
  /* box-shadow: 0 0 0 .2; */
  /* box-shadow: 0 0 0 .25; */
  /* box-shadow: 0 0 0 .25e; */
  /* box-shadow: 0 0 0 .25em; */
  /* box-shadow: 0 0 0 .25em aliceblue; */
  /* box-shadow: 0 0 0 .25em beige; */
  /* box-shadow: 0 0 0 .25em black; */
  box-shadow: 0 0 0 .25em blue;
}

/* Inline #6 | https://cityofdetroit.github.io/COD-Design-System/iframe.html?viewMode=story&id=components-organisms-navbar--offcanvas-responsive */

.nav-link:focus-visible {
  /* box-shadow: 0 0 0 0.25em rgba(0, 68, 69, 0.25); */
  /* box-shadow: 0 0 0 0.25em beige; */
  /* box-shadow: 0 0 0 0.25em black; */
  box-shadow: 0 0 0 0.25em blue;
}

The Solution

Override the $focus-ring-color SCSS variable and set it to blue instead of $primary in src/scss/_bootstrap-variables.scss.

Then regenerate the theme CSS using ./scripts/compile_styles.sh.

@sreidthomas
Copy link
Contributor

@maxatdetroit

  1. Should thouse rules be in the src/scss/_bootstrap-variables.scss file or do I need to add them?

  2. What's the full command to regenerate the. I just add yarn before that right?: ./scripts/compile_styles.sh.

@maxatdetroit
Copy link
Member Author

@sreidthomas

The $focus-ring-color SCSS variable probably isn't in the src/scss/_bootstrap-variables.scss file yet. You'll need to add it.

The full command to regenerate the stylesheets is just ./scripts/compile_styles.sh. Because it has a shebang on line 1, it can be called directly.

@maxatdetroit maxatdetroit added the a11y Digital accessibility. label Jul 24, 2024
@maxatdetroit maxatdetroit added the bug Something isn't working label Jul 24, 2024
@maxatdetroit maxatdetroit linked a pull request Aug 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Digital accessibility. bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants