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

Fix scrolling to new annotations #321

Merged
merged 1 commit into from
Mar 29, 2017
Merged

Conversation

robertknight
Copy link
Member

@robertknight robertknight commented Mar 29, 2017

Short version: Scrolling to new annotations which were off-screen failed because the function which computed the vertical offset to scroll the sidebar to when a new annotation was added always returned 0. This was due to using the wrong geometry property of document.body to get the height of the content.

The previous method happened to work prior to what should have been an innocent change in #306 which set the height of the <hypothesis-app> element to the height of the viewport.


Longer version: See #319 (comment)


Testing: Build a prod Chrome extension and follow the steps in #319

Fixes #319

Since #306 which set the height of the `<hypothesis-app>` container
element to 100%, the height of `document.body` is now equal to the
window's `innerHeight`. As a result, `document.body.clientHeight` now
returns the same value as `window.innerHeight` and `scrollOffset()`
returns 0.

Fix this by using `scrollHeight` instead of `clientHeight`, which takes
into account the height of all of the body's descendant elements,
including the `<thread-list>`.

This calculation would still return the wrong result if the
`<thread-list>` were ever placed in a separate scrolling container
within the sidebar app window, but that is an acceptible limitation for
now.
@codecov-io
Copy link

codecov-io commented Mar 29, 2017

Codecov Report

Merging #321 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #321   +/-   ##
======================================
  Coverage    76.6%   76.6%           
======================================
  Files         120     120           
  Lines        5887    5887           
  Branches      959     959           
======================================
  Hits         4510    4510           
  Misses       1377    1377
Impacted Files Coverage Δ
src/sidebar/components/thread-list.js 63.04% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55cc1f0...0908609. Read the comment docs.

@robertknight
Copy link
Member Author

I'm aware that this code would require some additional changes if we ever moved <thread-list> into an element in the sidebar that had its own scrollbar.

This PR also doesn't address the second issue I noted in #319 (comment) about when the scrolling happens, because the reason that it worked before still applies after this change. Fixing that properly will require some more meaty refactoring which should be done separately.

Copy link
Contributor

@sean-roberts sean-roberts left a comment

Choose a reason for hiding this comment

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

LGTM

@judell
Copy link
Contributor

judell commented Mar 29, 2017

Thanks!

@sean-roberts sean-roberts merged commit 53cebec into master Mar 29, 2017
@sean-roberts sean-roberts deleted the fix-scroll-to-new-annotation branch March 29, 2017 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants