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

Make font size dropdown more accessible. #33941

Merged
merged 8 commits into from
Aug 12, 2021
Merged

Make font size dropdown more accessible. #33941

merged 8 commits into from
Aug 12, 2021

Conversation

alexstine
Copy link
Contributor

@alexstine alexstine commented Aug 9, 2021

Description

The overall change in this pull request will allow screen readers to see the currently selected font size without having to open the menu. This message is communicated via aria-describedby. Since the aria-label overrides the button text, I had to provide a way for screen readers to see the currently selected font size value.

How has this been tested?

I tested this using NVDA, JAWS, and Voiceover. Browsers used include Firefox, Google Chrome, and Safari.

Screenshots

Types of changes

I guess you could consider this a Bug fix.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@alexstine alexstine self-assigned this Aug 9, 2021
@alexstine alexstine added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Accessibility Feedback Need input from accessibility labels Aug 9, 2021
@alexstine
Copy link
Contributor Author

I believe this is mostly ready for review. This brings a good improvement for the font size component as well as support for other components that may use this custom select box. This PR was primarily created for the font size fixes but there were a couple components involved that needed adjusting.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

The code change looks good to me and works well on my tests 👍

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

Tested with VoiceOver/Safari and NVDA/Firefox and this is working really well ✅

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @alexstine !

I was wondering if we should make this built in in the CustomSelectControl component. There are other usages of this component (check font weight, etc...) and we could use the a11y enhancement for all of them. For example we could have something like:

const describedBy = `Currently selected ${ label?.toLowerCase() }: ${
	selectedItem?.name
}`;

We could even have the new describedBy prop and if not provided, use something like the above snippet. What do you think?

@carolinan
Copy link
Contributor

Tested with NVDA and chrome on Windows, works well. +1 for using it in the component and solving the translation.

@alexstine
Copy link
Contributor Author

I made a few updates to the PR.

  1. I added a fallback if there was no describedBy text passed in.
  2. I decided it was better to allow describedBy to have a custom message passed in. See how descriptive I was able to make font size? Ideally, developers will follow suit and avoid one size fits all. However, if nothing is provided, number 1 takes care of that now.
  3. I added sprintf, translation, and translation comments.

Please let me know if an issue is spotted.

@ntsekouras Thanks for the suggestion. As you can see, I adapted your idea a bit, but I think it will work fine this way.

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @alexstine ! Great work 💯

This just needs the fixing of the linter issue. Maybe a better name to the var as well, but I don't consider this a blocker.

packages/components/src/custom-select-control/index.js Outdated Show resolved Hide resolved
packages/components/src/custom-select-control/index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Great work here, thanks! 💯

@ntsekouras ntsekouras merged commit ae56763 into WordPress:trunk Aug 12, 2021
@github-actions github-actions bot added this to the Gutenberg 11.4 milestone Aug 12, 2021
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). Needs Accessibility Feedback Need input from accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants