-
Notifications
You must be signed in to change notification settings - Fork 398
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
Fixes #6679 - patch to make component accessible #6693
Conversation
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.
This looks like a good start, thanks!
Something needs to be fixed on Travis CI, you should take a look: it must be green :)
In addition, you need to write new test cases.
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.
Hi @shristit thanks for your PR , and welcome to AMO community 🎉 . Before any maintainer review the PR, I am suggesting few changes to help you. It almost looks good. I added few comments , can you please update the PR according to those. Also you can run yarn prettier-dev
before pushing the changes
src/ui/components/Rating/index.js
Outdated
@@ -140,7 +143,7 @@ export class RatingBase extends React.Component<InternalProps, StateType> { | |||
key: `rating-${thisRating}`, | |||
onClick: undefined, | |||
onMouseEnter: () => this.onHoverStar(thisRating), | |||
title: this.renderTitle(rating, readOnly, thisRating), | |||
title |
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.
Can you please remove the extra space and add a comma after title
please :)
src/ui/components/Rating/index.js
Outdated
<React.Fragment> | ||
<button | ||
aria-describedby={id} | ||
type="buttn" |
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.
Nit: Can you please change it to button
.
src/ui/components/Rating/index.js
Outdated
@@ -131,6 +131,9 @@ export class RatingBase extends React.Component<InternalProps, StateType> { | |||
if (hoveringOverStar !== null) { | |||
isSelected = thisRating <= hoveringOverStar; | |||
} | |||
|
|||
const title = this.renderTitle(rating, readOnly, thisRating); | |||
|
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.
You have some trailing space here , can you please remove it.
@shristit hi, do you need help to update your PR? |
Hi I will be back to it next week, Have college exams
…On Tue, Oct 23, 2018 at 4:37 PM William Durand ***@***.***> wrote:
@shristit <https://github.com/shristit> hi, do you need help to update
your PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6693 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoV8GMZYlMPc4P8ODEHYPXDxhzAeXHbYks5unviLgaJpZM4XxIBw>
.
|
Codecov Report
@@ Coverage Diff @@
## master #6693 +/- ##
==========================================
+ Coverage 97.84% 97.84% +<.01%
==========================================
Files 249 241 -8
Lines 6810 6556 -254
Branches 1266 1243 -23
==========================================
- Hits 6663 6415 -248
+ Misses 133 126 -7
- Partials 14 15 +1
Continue to review full report at Codecov.
|
@shristit that looks good, but you need to write some tests now :) |
Hi William , I do not know how to write test case can you help me with that
please?
Thanks
|
@shristit Yep. So you need to edit this file: https://github.com/mozilla/addons-frontend/blob/c543050abd5b430018c100a1ee7640a32b5231c8/tests/unit/ui/components/TestRating.js You can see a list of functions starting with I think it would make sense to update this test case: addons-frontend/tests/unit/ui/components/TestRating.js Lines 186 to 193 in c543050
You can make sure the You should also look for a |
Hi @shristit, do you need help? Here is a test case you could write: diff --git a/tests/unit/ui/components/TestRating.js b/tests/unit/ui/components/TestRating.js
index 45f891b96..c57268f50 100644
--- a/tests/unit/ui/components/TestRating.js
+++ b/tests/unit/ui/components/TestRating.js
@@ -192,6 +192,26 @@ describe(__filename, () => {
});
});
+ it('renders an accessible button for each rating', () => {
+ const root = renderWithEmptyRating();
+ [1, 2, 3, 4, 5].forEach((rating) => {
+ const button = getStar({ root, rating });
+ const id = `Rating-rating-${rating}-title`;
+
+ expect(button).toHaveProp('aria-describedby', id);
+
+ // Each rating should have a `span` along with a button.
+ expect(root.find(`span[id="${id}"]`)).toHaveLength(1);
+ expect(root.find(`span[id="${id}"]`)).toHaveProp(
+ 'className',
+ 'visually-hidden',
+ );
+ expect(root.find(`span[id="${id}"]`)).toHaveText(
+ `Rate this add-on ${rating} out of 5`,
+ );
+ });
+ });
+
it('renders an accessible description for null stars', () => {
const root = renderWithEmptyRating();
|
Awesome, thanks @shristit! Did you understand the test case? |
Yay, thanks for the patch @shristit! 🎉 Your contribution has been added to our recognition wiki. Would you be interested in creating an account on mozillians.org? I'd be happy to vouch for you. |
No description provided.