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

Color picker improvements, first round #2680

Merged
merged 8 commits into from
Sep 29, 2017

Conversation

afercia
Copy link
Contributor

@afercia afercia commented Sep 6, 2017

This PR tries to address a first round of improvements to the Color picker buttons.

  • changes aria-current to aria-pressed, see screenshot below to check how this the way buttons and itneraction with them get announced
  • fix invalid HTML: buttons can't contain divs
  • add missing aria-label on the "remove color" button
  • make the Custom color picker toggle a real toggle that opens/closes the popover and uses aria-expanded
  • fix the focus style on the Custom color picker: adds an inner span and applies overflow: hidden on it instead of applying it on the button (I guess this button with gradients needs to be tested a bit in IE 11 / Edge)

Fixes #2679

@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Sep 6, 2017
@afercia afercia requested a review from mtias September 6, 2017 06:58
@codecov
Copy link

codecov bot commented Sep 6, 2017

Codecov Report

Merging #2680 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2680      +/-   ##
==========================================
- Coverage   33.77%   33.74%   -0.03%     
==========================================
  Files         191      191              
  Lines        5691     5695       +4     
  Branches      996      997       +1     
==========================================
  Hits         1922     1922              
- Misses       3189     3192       +3     
- Partials      580      581       +1
Impacted Files Coverage Δ
blocks/color-palette/index.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7f1223...a4d10f7. Read the comment docs.

@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2017

Screenshots to illustrate the interaction with Safari + VoiceOver:

screen shot 2017-09-06 at 08 54 44

when clicking:

screen shot 2017-09-06 at 08 54 49

when clicking again:

screen shot 2017-09-06 at 08 54 53

selected state:

screen shot 2017-09-06 at 09 01 49

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Apologies on the delay in reviewing this one.

<Popover
isOpen={ this.state.opened }
onClose={ this.closePicker }
onClose={ this.closeOnClickOutside }
Copy link
Member

Choose a reason for hiding this comment

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

As of deb86a7, Popover's onClose callback no longer passes the click event, since there can be many reasons a Popover might emit a close intent. The change here should be simply to change onClose={ to onClickOutside={

I expect you may need to git rebase origin/master and force push the branch for this to take effect, since #2697 was merged to master after your branch was created.

ref={ this.bindToggleNode }
aria-label={ __( 'Custom color picker' ) }
>
<span className="blocks-color-palette__custom-color-gradient"></span>
Copy link
Member

Choose a reason for hiding this comment

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

Minor: For brevity, React allows you to self-close tags: <span /> (Edit: I see this was written as such below, so more for consistency).

className={ className }
style={ style }
onClick={ () => onChange( value === color ? undefined : color ) }
aria-label={ sprintf( __( 'Color: %s' ), color ) }
aria-current={ value === color && __( 'Selected color' ) }
aria-pressed={ value === color ? true : false }
Copy link
Member

Choose a reason for hiding this comment

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

The ternary shouldn't be necessary here, and can be simplified to value === color (will always be true or false)

<Popover
isOpen={ this.state.opened }
onClose={ this.closePicker }
onClose={ this.closeOnClickOutside }
onClick={ this.stopPropagation }
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain the need for stopping propagation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm not 100% sure given the time passed, I think clicking anywhere on the ChromePicker (custom color) closed the popover but seems something has changed in the meantime (can't confirm). Will remove.

@afercia afercia force-pushed the update/color-picker-a11y-valid-code branch from f3c58b5 to bc81f6b Compare September 29, 2017 13:55
@afercia
Copy link
Contributor Author

afercia commented Sep 29, 2017

Updated and rebased. But I'm seeing a new CSS glitch in Safari 11, where the rounded focus style on the color buttons is not equally centered. Investigating.

screen shot 2017-09-29 at 15 54 19

@afercia
Copy link
Contributor Author

afercia commented Sep 29, 2017

@aduth any specific reason for this rule:
error A space is required before closing bracket react/jsx-space-before-closing

seems a bit weird to me this actually can make any relevant difference:

<span className="blocks-color-palette__custom-color-gradient"/>
<span className="blocks-color-palette__custom-color-gradient" />

@afercia
Copy link
Contributor Author

afercia commented Sep 29, 2017

The alignment issue in Safari 11 is solved in 0503875. Any objections to merge?

@aduth
Copy link
Member

aduth commented Sep 29, 2017

@aduth any specific reason for this rule:

Like rules on spacing within parentheses, it's merely a style convention aimed at encouraging consistency.

I would be glad to add these to the coding guidelines document but... the current atmosphere leads me to believe that it would be unwise to be codifying our React usage patterns at this point in time 😬

(Will follow-up with a final review)

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Removed unused stopPropagation method in a4d10f7. Otherwise LGTM 👍

@aduth
Copy link
Member

aduth commented Sep 29, 2017

Also, in case you're not already using one and are interested, there are a number of editor integrations to surface ESLint issues before it reaches CI: https://eslint.org/docs/user-guide/integrations

@afercia
Copy link
Contributor Author

afercia commented Sep 29, 2017

thanks!

@afercia afercia merged commit a596ceb into master Sep 29, 2017
@afercia afercia deleted the update/color-picker-a11y-valid-code branch September 29, 2017 19:58
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).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New color picker improvements, first round
2 participants