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

[A11Y] Add focus ring mixin to restore ring to elements which no longer have it #2814

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

davwheat
Copy link
Member

@davwheat davwheat commented Apr 29, 2021

Changes proposed in this pull request:

These mixins allow us to restore default browser focus rings on elements which no longer have them.

Reviewers should focus on:

I chose to make the styles mixin "private" as it shouldn't be used manually elsewhere in core -- we should instead use the other available mixins in the file. Is this the right choice?

Screenshot
image

This screenshot uses:

.add-keyboard-focus-ring();
.add-keyboard-focus-ring-offset(4px);

Confirmed

  • Frontend changes: tested on a local Flarum installation.

These mixins allow us to restore default browser focus rings on elements which no longer have them.
@davwheat davwheat added the type/accessibility Issues relating to accessibility (keyboard navigation, screenreaders, text contrast, etc.) label Apr 29, 2021
@davwheat davwheat requested review from SychO9 and askvortsov1 April 29, 2021 17:47
@davwheat davwheat self-assigned this Apr 29, 2021
@davwheat davwheat changed the title Add focus ring mixin [A11Y] Add focus ring mixin to restore ring to elements which no longer have it Apr 29, 2021
@askvortsov1
Copy link
Member

It doesn't seem like these are actually being used right now, unless I'm misunderstanding something?

@davwheat
Copy link
Member Author

davwheat commented Apr 29, 2021

No, but I'm writing some improvements for the Notifications styles which will require this.

I felt that putting it in its own PR made a bit more sense than combining it with the current almost whole rewrite of the styles.

(Grid and flex!)

@SychO9
Copy link
Member

SychO9 commented Apr 29, 2021

wouldn't it be easier to remove any outline: none on element that don't have it and let the browser do it ? or is it better for us to specify the outline ourselves ?

@davwheat
Copy link
Member Author

davwheat commented Apr 29, 2021

Removing outline: none is also good, but there are weird nuances and situations that result in outlines not existing anyway.

This is intended to be a temporary fix anyway -- I hope to get as many of our mixins removed as possible so we don't have border radius repeated 5 times when only one of them does anything :P

image


It could also allow for easier customisation of outlines if, for whatever terrible reason, someone wanted to do so.

@SychO9
Copy link
Member

SychO9 commented Apr 29, 2021

but there are weird nuances and situations that result in outlines not existing anyway.

that shouldn't be the case by default, what you're seeing locally (in the image) is most likely because you also technically have the button :active or something that sets off the outline as well (we probably have outline: none all over the place 🙈)

However you make a good point about customization! how does that work here, by overriding mixins ? I don't think that's possible in less 🤔, we might have to move the outline value to variables.less

@davwheat
Copy link
Member Author

In Less, mixins get merged together, with the later mixins taking precedence.

Though, saying that, moving it to a variable might be a good idea.

Should the variable be the entire value? I'm leaning towards that instead of splitting it into 3 separate ones.

@davwheat
Copy link
Member Author

Actually, we can't move it to a variable as we have two values to make it work. Leaving it as a mixin might be our only choice.

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Less, mixins get merged together, with the later mixins taking precedence.

Aha, interesting that's the case indeed!

Let's leave it as is then.

@davwheat
Copy link
Member Author

Just added a quick comment about how to override the outline styles, and switched to using a #private namespace instead of cluttering up the root namespace even more.

I'll give both of you a few mins to note any objections to that. I think core should have probably used a namespace for its own mixins from the start, and we should probably recommend extensions do the same.

@SychO9
Copy link
Member

SychO9 commented Apr 29, 2021

neat, no objections!

I think core should have probably used a namespace for its own mixins from the start, and we should probably recommend extensions do the same.

I like the idea, I think it'd be worth implementing that when we get to refactoring more of the frontend code. I think it'd be good to have an issue about it.

@davwheat
Copy link
Member Author

I've created a docs issue -- hopefully I'll get the chance to write a small bit about it before stable releases, and we can note that we strongly recommend switching to that: flarum/docs#322

@davwheat davwheat merged commit 8a431dc into master Apr 29, 2021
@davwheat davwheat deleted the dw/add-a11y-focus-ring-mixin branch April 29, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/accessibility Issues relating to accessibility (keyboard navigation, screenreaders, text contrast, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants