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

User autocomplete: The slug has too low color contrast #69001

Open
3 of 6 tasks
carolinan opened this issue Feb 3, 2025 · 8 comments · May be fixed by #69003
Open
3 of 6 tasks

User autocomplete: The slug has too low color contrast #69001

carolinan opened this issue Feb 3, 2025 · 8 comments · May be fixed by #69003
Assignees
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

When you type @ in the editor, a list of users is shown.
The list shows the avatar, the chosen display name from the user profile, and the user's slug.
The text for the slug has too low contrast on the item in the list that is selected.
It is #757575 on #007cba (contrast ratio 1:1) and hover it is #007cba on #006ba1 (1.26:1).
#007cba and #006ba1 are from the admin theme.

Step-by-step reproduction instructions

Type @ in the editor and select a user. Try to read the slug, which is the second name on the listed item.

Screenshots, screen recording, code snippet

A screenshot of the list of users, showing the text and background colors.

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@carolinan carolinan added [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 labels Feb 3, 2025
@SainathPoojary
Copy link
Contributor

Yes @carolinan, I agree this indeed is a issue, I would like to work on this.

@im3dabasia
Copy link
Contributor

Thank you, @carolinan, for raising this issue. I agree that this is an accessibility concern, and based on WCAG AA guidelines, we should have at least a contrast ratio of 4.5:1 for small text.

I propose changing the color from #757575 to #fff, as used in the Publish button on the top bar. This would ensure consistency and resolve the accessibility issue.

@carolinan
Copy link
Contributor Author

carolinan commented Feb 3, 2025

To be honest I would label this as a low priority, unless testing show that there are other elements of other autocompletes that also has contrast issues.


By setting the text color to white, the display name and the slug would be too similar, and it may be confusing because they would then have the same importance in the interface.
A parenthesis (in addition to the color change) may also not be suitable for de-emphasizing the slug, since the context is not exactly a sentence?

I found it confusing that the slug showed at all, but maybe it is important in some environments with many users.

@SainathPoojary SainathPoojary linked a pull request Feb 3, 2025 that will close this issue
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 3, 2025
@SainathPoojary
Copy link
Contributor

Hey @carolinan,

I was wondering if adding @ before the slug and reducing the font size to 0.7rem might help make it less prominent.

Here are a few visual comparisons for your reference:

With font size: 0.7rem and @:

Image

Without font size adjustment:

Image

With font size 0.7rem but without the @:

Image

@afercia
Copy link
Contributor

afercia commented Feb 3, 2025

maybe it is important in some environments with many users.

Yes I guess the slug helps differentiate users with similar usernames.

Due to my low vision I was really struggling to even understand the screenshot attached to this issue because to me the slug of the selected item is barely visible.

It is worth noting tha the color change of the selected item comes from the fact the button of the selected item becomes a primary button:

background: $components-color-accent;
color: $components-color-accent-inverted;

These colors use CSS variables that adapt to the admin color scheme set under the WP admin user profile settings. Instead, the user slug color is hardcoded in the component.

Screenshot with the default admin color scheme, 'Midnight' color scheme and 'Ectoplasm' color scheme

Image

While only the default admin color scheme is expected to be accessible, the background colos can't be predicted. As such, I think the slug color should use the same variable of the username color, maybe deemphasized with some Sass function?

@Rishit30G
Copy link
Contributor

Thanks for sharing the issue,

Since I was able to reproduce the issue, I found that using color: currentColor; instead of color: var(--wp-admin-theme-color); for the hover state resolves the problem. Also, setting the text color to something like color: rgb(191, 189, 189); instead of color: $gray-700; makes the username much more visible.

Sharing the screencast for the same:

Screen.Recording.2025-02-03.at.6.26.01.PM.mov

@SainathPoojary
Copy link
Contributor

Hi @Rishit30G,

I tested the suggested color using the ColorContrastChecker component in Storybook, and unfortunately, it did not pass the contrast check. Based on my findings, #FFFFFF(which is same color as name) was the only shade of gray that met the accessibility requirements.

However, if we use the same color for both the name and slug, they become indistinguishable. I think we need to explore a way to visually de-emphasize the slug to differentiate it better.

Looking forward to hearing your thoughts!

@Rishit30G
Copy link
Contributor

Hey @SainathPoojary,

It makes sense, thanks for sharing your thoughts on the above screencast! 👍🏻

For the hover part I think that we have wp-admin-theme-color on the hover ( non-selected ) so it makes sense to have the currentColor for the hover state ( selected ) for username text, that should be fine in my opinion

However for the non-selected/selected state, the username can have a colour somewhere in the lines of rgb(191, 189, 189); that was my thinking, but if it fails the accessibility criteria, then we should go with the approach shared in the above comment ( deemphasizing using sass function )

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). [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants