-
Notifications
You must be signed in to change notification settings - Fork 80
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: redirect to unit page if the hit or its parent is a unit #957
feat: redirect to unit page if the hit or its parent is a unit #957
Conversation
Thanks for the pull request, @rpenido! 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. |
33b131e
to
9798dc3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #957 +/- ##
==========================================
+ Coverage 92.02% 92.09% +0.06%
==========================================
Files 686 685 -1
Lines 11955 12090 +135
Branches 2598 2637 +39
==========================================
+ Hits 11002 11134 +132
- Misses 917 920 +3
Partials 36 36 ☔ View full report in Codecov by Sentry. |
fc5df69
to
0d38d98
Compare
0d38d98
to
9901d9b
Compare
64c630e
to
949b3c6
Compare
When I search for a component it does not redirect me to the unit page: https://www.loom.com/share/1c5633da07804908980a158e3dfc0289?sid=638b4634-5b63-461c-9206-5548d5ccf2e3 |
Hi @ChrisChV! Thank you for your input! |
0e4d37f
to
1954667
Compare
1954667
to
78dc0c4
Compare
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.
@rpenido Thanks! It works 👍
- I tested this: I followed the testing instructions
- I read through the code and considered the security, stability and performance implications of the changes.
- I tested that the UI can be used with a keyboard only (tab order, keyboard controls).
- Includes tests for bugfixes and/or features added.
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 this is looking good.
I just have one minor nit about reusing styles. The other point is entirely optional since I don't see anything wrong with the current implementation.
src/course-unit/CourseUnit.scss
Outdated
@keyframes glow { | ||
0% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
100% { | ||
box-shadow: unset; | ||
} | ||
} |
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 exact same animation already exists in CourseOutline.scss
, can you boost it to a more common location and reuse the code instead?
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 for the suggestion @xitij2000! I moved it here: 0493375
if (courseXBlockElementRef.current && (shouldScroll || isScrolledToElement)) { | ||
scrollToElement(courseXBlockElementRef.current); | ||
} | ||
}, []); | ||
}, [isScrolledToElement]); |
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.
FYI, there is another way to do this without using react state at all.
- Give the element a unique ID e.g. xblock-id-abcde
- Set the url hash to the above ID, i.e. "...some/url/page#xblock-id-abcde"
- Use the ":target" pseudo-class to apply the glow style.
If the URL fragment matches an ID the browser should automatically scroll to it, and it applies the :target
pseudo-class ref.
This means by using this mechanism you can avoid any code for scrolling, and applying a class. Also changing this value doesn't cause the page to refresh since it's client-side only.
The only disadvantage is that this is never passed to the server. What that means is that the server can't perform any action based on this value. Here since there is no server this is a moot point, but worth mentioning anyway.
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.
Awesome @xitij2000! Thank you for this.
Using targets here would be a better approach, but I think refactoring it (we already had some scrolling function feature) will put us out of schedule/scope.
But I think it is worth refactoring it next time we hit this feature.
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.
Certainly, that makes sense, and keeping this part of the JavaScript code also opens up other possibilities. No need for a refactoring already.
Hi @xitij2000 ! Could you do another pass and merge if everything is fine? |
@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR adds the feature to redirect from a search result to a Unit, in case the hit parent is a Unit, or the hit is a unit itself.
More Information:
Closes:
Depends on:
Testing Instructions
Private ref: FAL-3709