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

Fix/categories block label missing #10912

Merged

Conversation

Luciaisacomputer
Copy link
Contributor

Description

The categories block does not have a label when it is set to "Display as dropdown" as mentioned in #10871. This updates the markup in the admin to render a visually hidden label for assistive technology to provide context to the dropdown.

Also mentioned in the related issue above is that the labels should possibly be visual by default. Once merged, another PR can be opened to address that.

One thing to note is that various screen readers will respond differently to select dropdowns based on the type of label used (implicit vs explicit) so even though in my testing it never read the label because I was using VoiceOver and Safari, other browsers/screen readers will respond differently
(http://www.davidmacd.com/blog/select-box-label.html)

How has this been tested?

Tested on OSX in Chrome, Safari, Firefox, Edge, and IE11 using Browserstack. I used Voice Over + Safari to test that the label is properly read.

Screenshots

screen shot 2018-10-22 at 2 22 38 pm

screen shot 2018-10-22 at 2 24 40 pm

(My category name was test, which I now realize should probably be something a little more contextual)

Types of changes

Bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

Luke Pettway added 2 commits October 22, 2018 13:17
…element for the dropdown element using the unique instance ID. Applied Categories in the i18n helper for the label. Refactored a few props references to clean up the code
<label htmlFor={ `${ className }-${ instanceId }` } className="screen-reader-text">
{ __( 'Categories' ) }
</label>
<select id={ `${ className }-${ instanceId }` } className={ `${ className }__dropdown` }>
Copy link
Member

@gziolo gziolo Oct 23, 2018

Choose a reason for hiding this comment

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

I think id can be statically set in here to something like:

const selectId = `category-categories-select-${ instanceId }`;
...
<label htmlFor={ selectId } className="screen-reader-text">
....
<select id={ selectId } className={ `${ className }__dropdown` }>

Copy link
Contributor Author

@Luciaisacomputer Luciaisacomputer Oct 23, 2018

Choose a reason for hiding this comment

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

Thanks for the feedback, I'll make this change and push a commit when I find some time later today.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

I applied to minor fixes. It's goo to go. Thank you for working on this.

@@ -1,11 +1,16 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that loadash was located in the wrong section of imports. It's fixed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I wasn't sure what order to put it in I'll make sure to check out the documentation for the JS standards

const parentId = showHierarchy ? 0 : null;
const categories = this.getCategories( parentId );

const selectId = `blocks-category-select-${ instanceId }`;
Copy link
Member

Choose a reason for hiding this comment

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

I updated this id myself to align with other similar ids added in different places.

@gziolo
Copy link
Member

gziolo commented Oct 24, 2018

screen shot 2018-10-24 at 12 25 49

I can confirm it works as expected.

@gziolo gziolo added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Oct 24, 2018
@gziolo gziolo added this to the 4.2 milestone Oct 24, 2018
@gziolo
Copy link
Member

gziolo commented Oct 24, 2018

Also mentioned in the related issue above is that the labels should possibly be visual by default. Once merged, another PR can be opened to address that.

@tofumatt - what's your take on that?

@gziolo gziolo merged commit f661a76 into WordPress:master Oct 24, 2018
@gziolo gziolo added the [Type] Bug An existing feature does not function as intended label Oct 24, 2018
@tofumatt
Copy link
Member

I agree, we should file another issue for it; right now it just being a dropdown in the middle of content really lacks context for all users. Filed: #11002 and #11003.

antpb pushed a commit to antpb/gutenberg that referenced this pull request Oct 26, 2018
* added withInstanceId HoC to pass in unique instance. Created a label element for the dropdown element using the unique instance ID. Applied Categories in the i18n helper for the label. Refactored a few props references to clean up the code

* switch to id instead of name

* statically set class name in constant

* Move lodash to external dependencies section

* Change the name of the select id
@youknowriad
Copy link
Contributor

The issue also mentions that we should show this label on the frontend which is not the case with the PR. Any taker for a follow-up PR for the PHP side of things?

@joedolson
Copy link
Contributor

This seems to have been lost in the current trunk; there is no longer a label associated with the category block dropdown.

@youknowriad
Copy link
Contributor

@joedolson would you mind opening a new issue for this in order for us to debug it properly.

@youknowriad
Copy link
Contributor

Looking at the diff above, this adds the label in the editor but not in the frontend. I guess it was never fixed in the frontend.

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.

5 participants