-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 speak messages to the feature toggle component. #13385
Conversation
Note: locally, I get 2 tests failures:
both seem related to:
they happen also on master and seem completely unrelated to the changes in this PR. |
This is something related to npm, I will look into fixing it. I see it on other recently created PRs, too. |
1960f94
to
f6084bc
Compare
Rebased to incorporate the changes from #13395 and pass the tests. |
@@ -19,17 +19,32 @@ function WritingMenu( { onClose } ) { | |||
feature="fixedToolbar" | |||
label={ __( 'Top Toolbar' ) } | |||
info={ __( 'Access all block and document tools in a single place' ) } | |||
onToggle={ onClose } /> | |||
onToggle={ onClose } | |||
messages={ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here is that we pass an object constructor as prop. This will force FeatureToggle
to re-render whenever WritingMenu
re-renders which isn't optimal. Can we pass two string props instead to avoid such case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can. Just noting there are many, many, cases in the codebase where this pattern is used. If it's a real concern, then maybe it should be a guideline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a post which @youknowriad wants to write about performance and how to optimize towards it. I hope we can use it as a template for guidelines later.
@gziolo Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look great. I tested it with VoiceOver enabled and it works properly.
…rnmobile/372-add-title-to-gutenberg-mobile * 'master' of https://github.com/WordPress/gutenberg: (56 commits) Save package-lock.json file changes (#13481) Plugin: Deprecate gutenberg_add_responsive_body_class (#13461) Add speak messages to the feature toggle component. (#13385) Plugin: Deprecate gutenberg_kses_allowedtags (#13460) Plugin: Deprecate gutenberg_bulk_post_updated_messages (#13472) Plugin: Avoid calling deprecated gutenberg_silence_rest_errors (#13446) Plugin: Deprecate gutenberg_remove_wpcom_markdown_support (#13473) Fix: Categories block: add custom classes only to wrapper (#13439) is-shallow-equal: Use ES5 ruleset from eslint-plugin module (#13428) Update and Organize Contributors Guide per #12916 (#13352) Dismissible-notices: fix text overlapping icon (X) (#13371) Framework: Remove 5.0-merged REST API integrations (#13408) Plugin: Remove 5.0-merged block registration functions, integrations (#13412) Framework: Bump minimum required WP to 5.x (#13370) [Mobile] Improve keyboard hide button (#13415) Improve castError handling of non strings (#13315) Fix: File block add custom class (#13432) Consider making Fullscreen Mode effects visible only on larger screens (#13425) Update plugin version to 4.9.0 (#13436) DateTimePicker: fix prop warning for (#12933) ...
* Add speak messages to the feature toggle component. * Use plain props.
* Add speak messages to the feature toggle component. * Use plain props.
This PR adds
speak()
messages to theFeatureToggle
component.When toggling one of these features, screen reader users have no clue what happened. The menu closes, focus is moved back to the menu toggle button, and there's no audible feedback.
While the messages could be added to the store effects using
TOGGLE_FEATURE
, I've opted to add them directly in the component for a few reasons:BlockInspectorButton
seepackages/edit-post/src/components/visual-editor/block-inspector-button.js
I've opted for a
polite
message instead of anassertive
one because focus is moved back to the toggle button and the button needs to be announced. Anassertive
message would interrupt the screen reader preventing it from announcing where focus has been moved.To test:
polite
ARIA live region in the DOM gets the correct messagesFixes #13384