grommet / grommet

a react-based framework that provides accessibility, modularity, responsiveness, and theming in a tidy package
https://grommet.io
Apache License 2.0
8.35k stars 1.03k forks source link

Button tip string should be used for a11yTitle default value if none provided #5152

Closed samuelgoff closed 3 years ago

samuelgoff commented 3 years ago

Buttons and icon Buttons quite often need a tip value and a11yTitle value that is (or could suitably be) identical. The result is you end up repeating yourself, or declaring a const just so you only have to repeat the reference rather than the literal (or derivation), but it's still redundant.

Expected Behavior

If Button tip attribute is populated with a string but a11yTitle is not, then a11yTitle should get default value from the Button tip value. Not only does this solve a DRY opportunity, but this also ensures that if the a11yTitle value isn't populated, it will still allow the component to add a useful/meaningful aria-label value, improving accessibility with no additional effort on the part of the developer.

Actual Behavior

Create a Button and populate tip with a string but omit supplying an a11yTitle value, then elicit Tip visibility so you can examine the DOM. Note that the aria-label is not populated in the resulting button DOM.

URL, screen shot, or Codepen exhibiting the issue

https://codesandbox.io/s/grommet-v2-template-forked-w597x?file=/index.js

Steps to Reproduce

  1. Create a Button
  2. populate tip with a string but omit supplying an a11yTitle value
  3. elicit Tip visibility so you can examine the DOM
  4. Note that the aria-label is not populated in the resulting button DOM.

Your Environment

ShimiSun commented 3 years ago

I like this enhancement idea! The code contribution for this enhancement should be straightforward, would you like to take a stab at it? @samuelgoff

samuelgoff commented 3 years ago

Thanks Shimi, I already have it done & PR ready, but the battery on my laptop died before I could submit. Trekking home from getting the COVID vaccine, then I’ll be able to plug in & submit the PR.

Thanks,

Sam

Sent from my iPhone

On Apr 8, 2021, at 1:47 PM, Shimi @.***> wrote:

 I like this enhancement idea! The code contribution for this enhancement should be straightforward, would you like to take a stab at it? @samuelgoff

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

samuelgoff commented 3 years ago

I like this enhancement idea! The code contribution for this enhancement should be straightforward, would you like to take a stab at it? @samuelgoff

Hi @ShimiSun, hopefully this works for you.