Match the primary button disabled state to Core's color contrast#16103
Conversation
…re primary disabled buttons.
|
For comparison, @melchoyce included a mockup in the issue. Here it is below. |
kjellr
left a comment
There was a problem hiding this comment.
This is super close. Two things:
For the primary button, I noticed I can still click it. 🤔
Should that active state be removed?
Also, the primary button hex values are very close to the ones used in core, but they're not exact. Is there any way we can get those to match up exactly?
@kjellr I wasn't sure about changing the behavior because the a11y issue didn't offer suggestions for it. The only way I'm aware of how to do this is adding the
True. I'm dealing with tint/shade percentages here on |
|
I'm so stinking close on this, @kjellr, but the percentage tint/shade Sass change isn't allowing me to nail it. Do you suggest swapping out to hex values, or will that be too problematic for theming the editor (if that's what those variables are for)? This is where I'm at right now: Core hex values Gutenberg hex values |
|
Would be good to test this with other profile color schemes as well. |
It looks like for the color schemes, the disabled states are generated using the following mixin: We unfortunately can't use the exact same code here, since they require actual color values as inputs, not something like |
|
This looks like a big improvement to me 👍
I'm also not 100% sure about this. I'd love to get a second opinion here. |
In a few places, Gutenberg tries to avoid to use a When there are good reasons to do so, disabled controls can still be focusable, see: 5.7 Focusability of disabled controls Please refer to previous issues and discussions on this topic. |
|
Thanks, @afercia, that's what I was looking for.
I believe this primary button is a good reason to do so. I'll look into the link and figure out if something can be done here. |
|
I couldn't quite figure out how to add |
|
This looks great, thanks @mapk. I think the color is close enough to core that we can just keep as is. The only minor issue I'm seeing is with the Instead, I think we I think should keep the appearance in its disabled state, but add the outer focus borders: |
|
This last little change looks like below. It keeps the disabled text color when focused. @kjellr I had to add this CSS in a slightly awkward area b/c I couldn't get it working by keeping it all in the |
|
Danggit. I think I missed restricting the border addition on focus. |
kjellr
left a comment
There was a problem hiding this comment.
Thank you, @mapk!
@kjellr I had to add this CSS in a slightly awkward area b/c I couldn't get it working by keeping it all in the disabled button section. What do you think?
Yeah, I think it'd make sense to keep these styles alongside the other disabled styles. We can accomplish that by having those focus:enabled styles nested inside of the :disabled section. I've pushed a tiny change to take care of that. 👍
Re-reading through all the other comments, I'm fairly certain this is good to go. I'll merge in as soon as the tests pass. Thanks for your work on this!
| text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1); | ||
| text-shadow: none; | ||
|
|
||
| // This specificity is needed to override alternate color schemes in WP-Admin. |
There was a problem hiding this comment.
Hmm actually — I noticed that all the secondary admin color schemes show their box shadows & text shadows. We'll need to override these. 🤔
I pushed a tiny update that fixes this by using a little extra specificity. We can probably count on all buttons in Gutenberg having that is-button class, so I think that'll work fine for us. I'd love a gut check from someone else though before merging. @jasmussen do you have a moment to take a look by any chance?
There was a problem hiding this comment.
There was a problem hiding this comment.
Ah, sorry — take a look at that when the button is disabled. 🙂
Before:
After:
This is more in line with the disabled blue button colors in the PR:
The specificity is probably okay, and if you didn't notice any differences in the non-disabled state, that probably means it didn't break anything important. 😄
There was a problem hiding this comment.
I just tested the changes as well, @kjellr. Everything worked well. Can I get an approval on this PR?
There was a problem hiding this comment.
😄 Yep, I didn't want to approve it myself before, since I'd last made some changes to it. If we're both in agreement though, this is good to land! I'll add a comment.
|
Thanks everyone! 🎉 |
| &:disabled, | ||
| &[aria-disabled="true"] { | ||
| cursor: default; | ||
| opacity: 0.3; |






























Description
See #15280. This fixes the primary button's disabled view to match Core's primary disabled buttons. It should help the a11y issue raised in #15280.
Oh, it also fixes the default button state to match Core's too.
How has this been tested?
Locally.
Screenshots
BEFORE
AFTER
Types of changes
Minor CSS changes tweaking shade and tints of disabled buttons.
Checklist: