• Robert Knight's avatar
    Improve logic for scrolling sidebar to annotation with a given ID (#3360) · 66a5da9a
    Robert Knight authored
    The previous logic contained several errors and omissions which could
    result in the card not appearing at the top of the viewport after
    scrolling.
    
     1. If the set of visible threads changed multiple times before the timeout
        that triggered re-measuring of visible thread heights changed, then
        a measured height could be replaced with 0.
    
        Add checks to catch this.
    
     2. Account for the target scroll offset changing as a result of
        the document height increasing after the actual heights of
        cards become known and consequently the maximum possible
        scroll offset changes.
    
     3. Correct calculation of the position that we need to scroll the
        window to in order to have a card positioned at the top
        of the window. For the first card in the list, the position
        should be 0 (as returned by visibleThreads.yOffsetOf(...)),
        and for the Nth card it should be the total height of the N-1
        previous cards.
    66a5da9a
widget-controller-test.js 13.4 KB