Annotation scrolling to line UI bug fix #1807
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Changed
app/assets/javascripts/annotations.js
to fix the scroll animation jumping around when clicking on an annotation that was already in view. (Issue #1665 No. 5)The jumping animation was caused due to the entire code file being reloaded every time a user clicked on an annotation link (inside
annotations.js
, the functionattachChangeFileEvents
would always callchangeFile
and thus reload the code pane). This was fixed by adding a check to ensurechangeFile
would only be called if the header position (code file) of the annotation clicked was different from the current code file in view.Motivation and context
Previously, when we clicked on an annotation on the right side bar, we would start scrolling from the top of the code viewer each time (even if the annotation was already in view), which resulted in a buggy animation.
Before changes:
![before](https://user-images.githubusercontent.com/66969001/217990241-0c504f55-bfd3-4b94-8cb7-f7a1dac0d0c9.gif)
After changes:
![after](https://user-images.githubusercontent.com/66969001/217990396-93fb87e9-f331-415f-945e-b49fd01186f4.gif)
How has this been tested?
To test this bug fix, create a submission with multiple files (with at least one multiline file long enough to require scrolling within the Autolab submission viewer). Then, write an annotation for any line in the multiline file (preferably on a line not initially visible when the file is loaded, such that you have to scroll in order to view the line), and annotations in other files as well. Test by clicking annotations on the right side bar when:
Types of changes
Checklist
overcommit --install && overcommit --sign
to use pre-commit hook for linting