-
Notifications
You must be signed in to change notification settings - Fork 205
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: make nav buttons use links for accessibility #1137
Conversation
Thanks for the pull request, @mohd-akram! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
@BbrSofiane, @brian-smith-tcril, would you mind triggering the CI? |
It didn't seem to run the tests till the end. Failed midway with this:
|
let nextLink; | ||
if (isLastUnit) { | ||
nextLink = `/course/${courseId}/course-end`; | ||
} else { | ||
const nextIndex = unitIndex + 1; | ||
if (nextIndex < sequence.unitIds.length) { | ||
const nextUnitId = sequence.unitIds[nextIndex]; | ||
nextLink = `/course/${courseId}/${currentSequenceId}/${nextUnitId}`; | ||
} else if (nextSequenceId) { | ||
nextLink = `/course/${courseId}/${nextSequenceId}/first`; | ||
} | ||
} | ||
|
||
let previousLink; | ||
const previousIndex = unitIndex - 1; | ||
if (previousIndex >= 0) { | ||
const previousUnitId = sequence.unitIds[previousIndex]; | ||
previousLink = `/course/${courseId}/${currentSequenceId}/${previousUnitId}`; | ||
} else if (previousSequenceId) { | ||
previousLink = `/course/${courseId}/${previousSequenceId}/last`; | ||
} |
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.
We can probably have two functions, getNextLink, getPreviousLink, and the logic can be moved into them, it will help to maintain the code and to find them. What do you think?
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.
We could, but it will duplicate some logic (eg. isLastUnit). I'm also not sure where I'd put them.
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.
I think you can create a series of interdependent hooks.
i.e. useNextLink, and usePreviousLink, that can both use common hooks. i.e. they can both pull in use a common hook that returns isLastUnit
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.
👍
- I tested this: all buttons work and show as expected.
- I read through the code.
- This MFE is now more accessible. 🙂
If anyone has any idea how to fix this or if it's just an intermittent error, re-run the tests, that would be appreciated. EDIT: I've verified that this is an intermittent error and the tests should pass. |
@BbrSofiane, @brian-smith-tcril, could you please trigger the CI again? |
@mohd-akram Thank you for this contribution! |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1137 +/- ##
==========================================
+ Coverage 87.67% 87.89% +0.21%
==========================================
Files 264 264
Lines 4455 4477 +22
Branches 1113 1123 +10
==========================================
+ Hits 3906 3935 +29
+ Misses 535 528 -7
Partials 14 14
☔ View full report in Codecov by Sentry. |
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.
👍
- I tested this: tested the navigation locally
- I read through the code
- I checked for accessibility issues
- Includes documentation: n/a
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-secure
repository: n/a
@BbrSofiane, @brian-smith-tcril, would you like to review this as CC? It closes an issue reported in this repo (#753). |
@mattcarter FYI^^ Please let us know if you're planning to have someone from the Aurora team look at these changes as well. |
Hey @BbrSofiane and @brian-smith-tcril, friendly ping about @Agrendalath's question above. CC @mattcarter |
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.
Thank you so much for this! I left a few comments with questions, but overall this is looking great!
@@ -1,4 +1,5 @@ | |||
import React from 'react'; | |||
import { Link } from 'react-router-dom'; |
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.
Is there a reason we aren't already using these? This feels like it simplifies the implementation quite a bit (which I'm all for!). I'm worried I don't have enough context on the original implementation to know if that was an intentional architectural decision or not. I'm just not sure if there's something I'm missing that prevented use of react-router links in the first place.
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.
No idea. I can see that react router links are used in some other places (eg. CourseBreadcrumbs).
@mohd-akram Looks like this is getting close to merging! If you could fix the remaining |
Fixed. |
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.
From high level, LGTM
@mohd-akram 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Thanks @mohd-akram ! 🎉 |
Closes #753
Testing instructions
npm test