-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Buttons: Neutral, hover, active and focus styles #904
Comments
CC: @afercia |
For controls (buttons, links, and form elements) in the "frame" around the editor, that is toolbar, sidebar, and "meta boxes" after the editor, I'd personally prefer to see as much integration as possible with the various state styles already used by core. From an accessibility perspective, they're already tested and have a decent accessibility. From an UI/design perspective, I think the WordPress design team should be involved 🙂 For controls within the editor, I'm all for custom styles, if needed. Pairing hover and focus is often a good choice, should be evaluated on a case by case basis though. As far as I know, for now two main styling are used:
Any feedback from other accessibility people very welcome 🙂 |
These are looking really nice! One state that should probably be added to the Block Control Buttons is Toggled + And related to toggling, I'll just throw out this article posted recently on CSS Tricks: "User Facing State". (There are some other good posts with the same recommendation, this is just the recent one I remember.) When possible, hopefully these buttons can be styled in a way that requires semantic markup! i.e. |
As a small update on this, I realized that the previously linked codepen with the Thankfully the fix is somewhat easy, and the on-click-outline removal is only for a few specific buttons and styles. The fix is to unstyle the custom WP focus outline that's set using https://codepen.io/joen/pen/XRLeNd?editors=1100 Edit: looks like it's more complicated than that. The focus rectangle lingers if the element is a |
I don't think this is something that needs to be "fixed". As noted also in other issues, visual focus should always be very clear, for all users. It's not something that benefits only keyboard users. Understanding SC 2.4.7 (Visual Focus) I understand all the "visual" concerns, however WordPress aims to be an usable and accessible application. It doesn't necessarily need to "look pretty". Instead, it needs to be accessible. I'd also remind that any new code in WordPress is required to meet the WCAG guidelines at level AA. I'd also note that I don't see a good reason to deviate from features that WordPress already implements. WordPress already provides focus styles, and it does that pretty decently. Why Gutenberg should have different rules? |
To be absolutely clear, focus styles are important. We should have them. I was also perhaps premature suggesting a "fix was easy". In fact I'm still investigating. Can you take a look at https://codepen.io/joen/pen/gRYazN and see what behavior you are seeing? I'm seeing a different lingering focus (when clicking) only on styled buttons, which very much seems like a browser bug to me. The behavior also varies from browser to browser, so looking at various implementations I'm first trying to detect what's going on. |
@jasmussen the browsers native behavior greatly differs not only across browsers but also across platforms. I've just re-tested a native button on Windows and it's completely different compared to macOS, not a surprise I guess. Apart from these academic considerations, the WCAG are really clear about this. Have you read what the WCAG require? Just to understand if we're on the same page. |
I have read those documents, but as I'm sure you've noticed I sometimes don't understand all the nuance, which is why I'm grateful that you often help provide direction. I'm working on a PR right now, and I was going to bring this up in #accessibility some time tomorrow, so as to not exhaust you specifically. My confusion currently stems from the different ways browsers treat this. All of these guidelines refer to keyboard focus, and suggests an outline. Combined with one of your past statements, that it's almost always best to rely on the stock implementation rather than designing your own, I've been looking at how Chrome, Firefox and Safari treat the unstyled This is similar to MacOS. There's a clearly distinct visible outline when the elements receive keyboard focus. And there's a clearly distinct button press style. But there's no visible outline when the mouse clicks on the button (i.e. mouse focus). Unless, of course you style the button, which is why I'm suggesting it's a bug. |
This link may be useful but it also suggests that the fix is really convoluted [and maybe not worth pursuring?]. |
This may be one of the reasons for being a bit confused. The guideline is about Visual Focus. Then, it calls it "keyboard focus" introducing some confusion. The second part of "Understanding SC 2.4.7 (Visual Focus)" clarifies that it's not just about keyboard users. As per the native browsers behavior, in this case is really inconsistent and hard to trace. To my understanding, natively buttons are designed by the platform. Some browsers (i.e. webkit) choose to override this and make their own buttons. This differs based on the platform too. For example, this is Firefox 53 on Windows 10: Regardless, the Guideline 2.4 and specifically Understanding SC 2.4.7 is very clear in illustrating the intent of the guideline. One of the examples there is about people with attention limitations, etc. who are not supposed to be keyboard users, no? (well they might be, but not necessarily :)) |
What is the intent of Understanding SC 2.4.7 in mentioning this as an "additional" technique:
In what way is this considered supplementary to "Sufficient Techniques"? Maybe I'm misunderstanding the format of the document and what is implied by "Additional". |
About that post, I just demonstrated with the screenshots posted on cloudup that it's based on wrong assumptions, for examples when it states:
that's not true on Windows. |
@aduth I guess we should ask the people who wrote that 🙂 I don't see a great difference from the "sufficient" techniques above. |
I started testing gutenberg a bit, and I immediately noticed box shadow around the sidebar toggle buttons. Immediately I was annoyed because I usually don't like focus styles, but from the a11y side they are definitely a must have. But still, to me, the current focus is 'too tight' around it. We should add 2 or 3 pixels of padding around those buttons. Without padding: With 3px padding: I played a bit and added a border instead of box-shadow on the focus, but I don't know if that would be clear enough from a11y standpoint, from visual standpoint I think that it looks prettier :D These are just quick inspector changes. |
Nice, I think that bottom border style could be interesting to explore. So thanks for your comment! A few things to unpack, though:
The metabox buttons, absolutely agree it's very intrusive there. But we could alleviate a great deal of it by making the button itself fill the whole area of sidebar, so it doesn't appear to be "a button inside a grid", but rather that the grid itself is buttons. I.e. something like this: |
Closing this in favor of #3039 |
Let's discuss and find a consensus on how buttons should look and behave when interacted with by mice and keyboards, and then roll this out to every element used. Much of this work is inspired by #846, #835, as well as a few slack conversations.
Let's start with an updated blueprint:
This shows and labels the elements of the editor. Focusing on buttons (and ignoring those provided by WordPress like Publish), we have these:
Mockup:
In the above mockup, the "Tab Focus" shows up when you tab into an item with the keyboard. The "Active + Focus" shows up when you click the item with your mouse, using the approach outlined here. You can try the behavior in this codepen: https://codepen.io/joen/pen/OmqQGR
The text was updated successfully, but these errors were encountered: