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

minor a11y: <select> has no visual indicator when tabbed to #1771

Closed
mustafa0x opened this issue Jul 17, 2022 · 5 comments
Closed

minor a11y: <select> has no visual indicator when tabbed to #1771

mustafa0x opened this issue Jul 17, 2022 · 5 comments

Comments

@mustafa0x
Copy link

No description provided.

@simonw
Copy link
Owner

simonw commented Dec 18, 2022

@simonw simonw added the css label Dec 18, 2022
@simonw
Copy link
Owner

simonw commented Dec 18, 2022

The border is actually on the div that wraps the select box:

image

I tried adding a border: 1px dotted black to select:focus but it's not quite right - it jumps around a bit like this:

Tabbing to the selects shows a 1px border but the element expands in size by one pixel, causing a visual jump

@mustafa0x
Copy link
Author

the problem is:

.select-wrapper select:focus {
  outline: none;
}

I sometimes add this js:

window.addEventListener('keydown', function check_tab(e) {
    if (e.key === 'Tab') {
        document.documentElement.classList.add('user-is-tabbing')
        window.removeEventListener('keydown', check_tab)
    }
})

and then in the css, using a html.user-is-tabbing selector undo any outlines I removed.

@simonw
Copy link
Owner

simonw commented Dec 18, 2022

This does the trick:

div.select-wrapper:focus-within {
  border: 1px solid black;
}

tab-select-border-fix

@simonw simonw closed this as completed in a21c00b Dec 18, 2022
@simonw
Copy link
Owner

simonw commented Dec 18, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants