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

Accessibility: Fix custom color palette #62753

Merged
merged 5 commits into from
Jun 25, 2024
Merged

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Jun 21, 2024

What?

Makes the custom color palette options more accessible. Fixes #62728, at least partly.

Why?

The current setup is very overcomplicated and buggy. There's a wrapper button which is used to "edit a color", and only on click shows the input and remove button, but instantly puts focus in an unescapable popover.

How?

  1. Always should the input and remove button.
  2. Make the color indicator a button, which opens the popover.
  3. Define an onClose function for the popover.

Testing Instructions

Go to Site Editor → Styles → Colors → Palette.
Add a custom color and press Done.
Click the three dots and then "Show details".
All fields should be focusable for each button.
When editing the color, it should be possible to escape the popover.

Testing Instructions for Keyboard

Screenshots or screencast

@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 21, 2024
@ellatrix ellatrix requested a review from ajitbohra as a code owner June 21, 2024 14:59
Copy link

github-actions bot commented Jun 21, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@joedolson
Copy link
Contributor

Can I ask that we provide testing information that uses the names of things as they're exposed in the editing environment? There's nothing literally called "Global Styles" in the editor, so it's difficult for outside users to make use of those instructions to locate the item to be tested.

I believe this is referring to the color options in the Stylebook, but please confirm.

@ellatrix
Copy link
Member Author

It's called "Styles". I think it used to be called Global Styles and people still refer to it by that name

image

@joedolson
Copy link
Contributor

This is definitely a significant improvement.

I'd still very much like to see two changes:

  1. Have a 'cancel' option in the color popover, so that it's possible to change a color, then return to the previous color without needing to have the hex value memorized. Right now, if you change a color, but don't have the previous value recorded, there's no way to return to the previous color.

  2. Have the esc key trigger the cancel behavior, and have a button available to save the changes. I think that a click outside of the popover should be treated as a completion action; but escape should be treated as a cancellation.

@afercia
Copy link
Contributor

afercia commented Jun 24, 2024

Thanks for looking into this @ellatrix
It does solve some of the issues discovered on #62698 and then reported on #62728

I'd agree with @joedolson that the color picker would need Cancel and Save buttons. Not sure if that can be addressed in this PR or separately, as it appears to be a broader issue with the color picker.

I'd suggest two further improvements to be made, if possible, in this PR:

For consistnecy, the focus style of the new button to edit custom colors should be, ideally, a circular outline. Screenshot of the two different focus styles of the color buttons:

Screenshot 2024-06-24 at 09 44 35

When removing a custom color by pressing the minus icon button 'Remove color', focus should be managed to avoid a focus loss. I'd think the only reasonable place to move focus to would be the plus icon button 'Add color'.

Copy link
Contributor

@afercia afercia left a comment

Choose a reason for hiding this comment

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

Please see last comment.

@ellatrix
Copy link
Member Author

I can check again later today. I'd like this PR to be included in RC1, so it should be ready today, but I have a few other things to work through first.

@ellatrix
Copy link
Member Author

To me even the focus outline might be need a larger change (needing to pull in and extracting other components), so I'm not sure if it should block this improvement tbh... I went for the quick fix of wrapping the color in a Button.

@ellatrix
Copy link
Member Author

I could try to prevent the focus loss on remove though 👍

@afercia
Copy link
Contributor

afercia commented Jun 24, 2024

I'd agree it would be good to have these improvements in the RC. Further fixes can be done as follow-up in #62728

@ellatrix
Copy link
Member Author

@afercia I fixed the focus loss.

@ellatrix
Copy link
Member Author

Let's do this PR instead of #62698.

@ellatrix ellatrix force-pushed the fix/custom-color-palette-a11y branch from 76111ef to 52e2063 Compare June 24, 2024 18:35
@afercia
Copy link
Contributor

afercia commented Jun 25, 2024

I fixed the focus loss.

@ellatrix thanks. I'm not sure the 'Done' button is the right choice though. When there's only one custom color, removing it will also make the 'Done' button disappear so in this case focus is lost anyways.

@ellatrix
Copy link
Member Author

ellatrix commented Jun 25, 2024

@afercia Where do you suggest it to move?

@afercia
Copy link
Contributor

afercia commented Jun 25, 2024

I'd think the only reasonable place to move focus to would be the plus icon button 'Add color'.

Although not ideal, I think the 'Add color' button is the only one that is guaranteed to be always rendered?

@ellatrix
Copy link
Member Author

I'm not sure I have time left to fix this, I need to release the editor packages asap. If not, this will slip to 6.7

@afercia
Copy link
Contributor

afercia commented Jun 25, 2024

I can try to have a look at it.
Oh, I see also the Add color button is rendered conditionally on ! canOnlyChangeValues :/

@afercia
Copy link
Contributor

afercia commented Jun 25, 2024

After 262a486 focus is now moved back to the 'Add color' button when removing a color. When users canOnlyChangeValues, the focus loss doesn't occur in the first place because there's no 'Remove' button.

This UI would need more work as there are other focus losses and room for accessibility improvements but I'd think this PR is an improvement that would be nice to have in the 6.6 release.

@ellatrix
Copy link
Member Author

Great, thanks @afercia! Could you approve the PR? I'll merge it and cherry pick it onto the release branch

@ellatrix ellatrix added Backport to WP 6.6 Beta/RC and removed Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 25, 2024
@afercia
Copy link
Contributor

afercia commented Jun 25, 2024

Done, thanks 👍🏽

@ellatrix ellatrix merged commit e618232 into trunk Jun 25, 2024
66 checks passed
@ellatrix ellatrix deleted the fix/custom-color-palette-a11y branch June 25, 2024 10:42
@github-actions github-actions bot added this to the Gutenberg 18.7 milestone Jun 25, 2024
Copy link

There was a conflict while trying to cherry-pick the commit to the wp/6.6 branch. Please resolve the conflict manually and create a PR to the wp/6.6 branch.

ellatrix added a commit that referenced this pull request Jun 25, 2024
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
ellatrix added a commit that referenced this pull request Jun 25, 2024
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
@ellatrix
Copy link
Member Author

Manually backported this in #62824

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Styles: the edit Palette UI is not operable with a keyboard
3 participants