Add a focus outline to interactive elements #6948
Open
+44
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this PR?
I added a focus outline to interactive elements. The focus outline is still reset globally, but then re-enabled with focus-visible for keyboard use. Focusable elements get a focus outline only if they are focused while tabbing.
Text inputs and textareas are an exception to this logic, since they always match the pseudo-class
:focus
pseudo-class because they expect keyboard inputs.I can remove the focus outline for text inputs, but it would be useful to think about whether the input fields should also have a custom focus state. For example, by making the border of the element darker.
A modern progressive enhancement would be a solution with
:has
:I tried not to make any major design decisions, the outline is based on the default outline of the UA stylesheet. Custom focus states would of course improve the experience.
Why?
An important element for keyboard usability is the focus outline. Generally, overriding the browser's default outline is a bad idea.
Visual representation in Chromium browsers
I am aware that this change has an influence on the design of the admin interface and probably has to be discussed internally. If design adjustments are necessary, I can implement them with pleasure.