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

Add announcement on formatting change for screen readers #35896

Merged
merged 8 commits into from Nov 3, 2021

Conversation

@alexstine
Copy link
Contributor

@alexstine alexstine commented Oct 23, 2021

Description

When formatting text with items such as Code, Superscript, Subscript, etc, there is now an alert for screen readers to announce that the formatting has been added/removed. I also added this for Bold, Italics, and Underline. However, the alert will only be fired on shortcut key, not button click. Double feedback isn't really needed due to aria-pressed="true".

The only item not modified is text-color/Highlight. That needs it's own set of accessibility enhancements and I will do this in another PR.

I also added description text to the More menu and added role="menuitemcheckbox" that way users can tell if an item is enabled or disabled. I kept the alerts here as the More menu closes before checked/unchecked state is read. There is a similar issue for the Alignment Control which I may attempt to fix later.

How to test

Test 1

For this test, you will hear that formatting is applied/removed while using the keyboard.

  1. Open the Gutenberg editor.
  2. Navigate to a block or add a fresh block.
  3. Select some text. For this example, I selected some text within a Paragraph block by holding down Shift+Right Arrow until I captured my selection.
  4. Toggle Bold with CTRL+B and you should hear "Bold applied."
  5. Remove Bold with CTRL+B and you should hear "Bold removed."
  6. Try this out with other formatting shortcuts.

Test 2

In this test, you will explore the block formatting toolbar.

  1. Open the Gutenberg editor.
  2. Navigate to a block or add a fresh block.
  3. Select some text. For this example, I selected some text within a Paragraph block by holding down Shift+Right Arrow until I captured my selection.
  4. Press Shift+Tab to focus the Block Toolbar.
  5. Press Right Arrow until you hear More. I added some description text to this button, so you should hear "More, Displays more block tools" with NVDA or JAWS. With Voiceover, you should hear "More, this item contains help tag." Of course, what you hear depends on the verbosity setting of the screen reader.
  6. Open the More menu by pressing Enter.
  7. Notice how the menu items that toggle formatting such as Highlight or Inline Code are now checkboxes that way you can hear the current state of the item and if it is applied to the content you have selected.
  8. Try selecting Inline Code. You should hear "Inline Code applied" and the More menu should close. Focus should be placed back on the selected text within the block you are currently editing.
  9. Press Shift+Tab to enter the Block Toolbar.
  10. Navigate via Right Arrow to the More menu and open it with Enter.
  11. Notice how Inline Code currently says "Inline Code, checked" as the formatting option is currently applied.
  12. If you select Inline Code again to remove the formatting, you should hear "Inline Code removed" and focus should be placed back on the selected text within the block you are currently editing.

How has this been tested?

I tested using NVDA in Firefox. I checked to see which code called the function I modified and ensured params were updated.

Screenshots

Types of changes

This is a new feature.

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).
@carolinan
Copy link
Contributor

@carolinan carolinan commented Nov 2, 2021

I did a before and after comparison with NVDA and Chrome on Windows and the PR is working as described.

I am not the target user for this feature as I am not a screen reader user, but I agree it is an improvement since there were no announcements before this PR.

I did not do a code review.

Loading

@joedolson
Copy link

@joedolson joedolson commented Nov 2, 2021

Tested with NVDA/Chrome.

This is pretty slick; I didn't encounter any issues testing, and definitely agree that this is an improvement.

Loading

@alexstine alexstine requested review from noisysocks and talldan Nov 2, 2021
@alexstine
Copy link
Contributor Author

@alexstine alexstine commented Nov 2, 2021

Thanks @joedolson and @carolinan for testing.

This is ready for code review. @noisysocks do you think this can land before Friday so it can go in to 11.9? If not, this should be perfect for following release after WordPress 5.9.

Thanks. 💯

Loading

Copy link
Member

@noisysocks noisysocks left a comment

I don't think it's a "must have" for 5.9 so I won't add it to the board but I'm confident we can get it merged in time anyway.

Loading

packages/format-library/src/bold/index.js Outdated Show resolved Hide resolved
Loading
@alexstine
Copy link
Contributor Author

@alexstine alexstine commented Nov 3, 2021

@noisysocks Where exactly should I define the title for the announcement? I agree with you about the positional args situation but not sure where else to define this. The other nice thing about the toggleFormat() function is that I can tell if the format is being added or removed. I just don't know how I can get the title of the formatting button any other way than passing it directly as an arg. I know I can get say a list of blocks easily as I can access the block-editor store, but didn't look so simple for formatting buttons.

Loading

@alexstine
Copy link
Contributor Author

@alexstine alexstine commented Nov 3, 2021

@noisysocks Sorry about that, ignore my question. You gave me an example and I looked over it. Let me get it updated. That makes sense.

Loading

@alexstine
Copy link
Contributor Author

@alexstine alexstine commented Nov 3, 2021

@noisysocks Alright, fixes made. If you spot anything else, I'll likely be back on this tomorrow. 👍 Thanks.

Loading

@noisysocks
Copy link
Member

@noisysocks noisysocks commented Nov 3, 2021

I have to step out so can't test right now but the code LGTM 👍

Loading

@carolinan carolinan merged commit 0638a8c into WordPress:trunk Nov 3, 2021
20 checks passed
Loading
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Nov 3, 2021
carolinan added a commit that referenced this issue Nov 4, 2021
* Add announcement message for Bold toggle for screen readers.

* Speak update on toggleFormat().

* Try to fix tests.

* Only fire alert on keyboard shortcut unless it is an item only accessible from menu item.

* Render menu items as checkboxes.

* Make More button more descriptive.

* Add description text to More menu. Fix incorrect role for text-color.

* Store title in format object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment