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

feat(radio): support aria-label(ledby) on md-radio #596

Merged
merged 1 commit into from
Jun 2, 2016
Merged

feat(radio): support aria-label(ledby) on md-radio #596

merged 1 commit into from
Jun 2, 2016

Conversation

MartinMa
Copy link
Contributor

@MartinMa MartinMa commented Jun 1, 2016

Adds feature #586
radio: adding actionName attribute as label fallback (aria-label)

Added

  • tests
  • revised the documentation
  • and improved the examples/demo.

Please give me feedback, in case something needs to be changed.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 1, 2016
@@ -54,6 +54,7 @@ The `md-radio-group` component has no button initially selected.
| `value` | `any` | The value of this radio button. |
| `checked` | `boolean` | Whether the radio is checked. |
| `disabled` | `boolean` | Whether the radio is disabled. |
| `actionName` | `string` | Used to set the `aria-label` attribute of the underlying input element. |
Copy link
Member

Choose a reason for hiding this comment

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

This should be aria-label. We just want to forward the attribute.

  • As same as in the slide-toggle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is not a good idea to have a pseudo aria-label attribute on the MdRadio component and at the same time a real one on the underlying input element. It might confuse screen readers and its users. Do you know what I mean? That's why I chose a different name as seen on the Angular 2 documentation for template syntax (see Property Binding / We must use attribute binding when there is no element property to bind).

But while taking a look a the current implementation for MdSlideToggle, I see that the property used there is named ariaLabel, which is different from aria-label. So this subtle difference is probably enough avoid potential issues with screen readers.

So if everyone agrees and doesn't see any more issues, I can change the property name (and add aria-labelledby as well).

Copy link
Member

@devversion devversion Jun 1, 2016

Choose a reason for hiding this comment

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

We also use the aria-label input in the checkbox as well. (See here).

Screenreaders shouldn't be confused about that attribute, because the host element is normally not focusable.

Without any attribute binding, you're always using the dash cased attribute

<md-radio-button aria-label="My Label Input">

But with an attribute binding, it will be the camel-cased attribute name.

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 for the explanation. I will conform to the pattern used for the checkbox component.

@jelbourn
Copy link
Member

jelbourn commented Jun 1, 2016

Agreed on all of @devversion's comments

@MartinMa
Copy link
Contributor Author

MartinMa commented Jun 2, 2016

I updated the pull request.

  • Changed property to ariaLabel (corresponding attribute is called aria-label).
  • Added property ariaLabelledby (corresponding attribute is called aria-labelledby).
  • Updated tests and added new tests.
  • Updated README.
  • Removed demo/example code.

Let me know, if this is ok. I will squash all commits then, so it will be ready to be merged.

});

it('should not add aria-label attribute if not defined', () => {
expect(fruitRadioNativeInputs[1].getAttribute('aria-label')).toBe(null);
Copy link
Member

Choose a reason for hiding this comment

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

I'd use hasAttribute here and in other tests where you're checking for the presence of the attribute.

@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

Looks good aside from that one minor comment

@jelbourn jelbourn changed the title feat(radio): add actionName property used to set aria-label attribute feat(radio): support aria-label(ledby) on md-radio element Jun 2, 2016
@jelbourn jelbourn changed the title feat(radio): support aria-label(ledby) on md-radio element feat(radio): support aria-label(ledby) on md-radio Jun 2, 2016
@MartinMa
Copy link
Contributor Author

MartinMa commented Jun 2, 2016

Thanks for the feedback. I updated the two tests to use hasAttribute and squashed all commits. 🔨

@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

LGTM

@jelbourn jelbourn merged commit 8ccc49b into angular:master Jun 2, 2016
@jelbourn
Copy link
Member

jelbourn commented Jun 2, 2016

Thanks!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants