• 
      

    Update the diff file index when diffs are expanded/collapsed.

    Review Request #13235 — Created Aug. 23, 2023 and submitted

    Information

    Review Board
    release-6.x

    Reviewers

    The diff file index in the Unified Banner only updated extents when new
    diffs were added, when going into docked mode, or on window resize. If a
    diff was expanded or collapsed, the diff file index didn't know about
    this, and could present the wrong entries for the current view.

    We now use a ResizeObserver to track resizes to all the diffs,
    updating the extents whenever a resize is detected.

    To avoid duplicate calls to updateLayout() where this is computed
    (which could occur due to a window resize alone, or a window resize
    along with a ResizeObserver event), we now call a
    queueUpdateLayout() function, which will use requestAnimationFrame()
    to schedule updateLayout(). This, along with storing a request ID,
    prevents us from doing any unnecessary work that could lead to sluggish
    resizes.

    Unit tests pass.

    Tested expanding and collapsing diffs, resizing the window, and manually
    altering the DOM, verifying that layout updates were always called and
    the diff file index always showed the correct result.

    Summary ID
    Update the diff file index when diffs are expanded/collapsed.
    The diff file index in the Unified Banner only updated extents when new diffs were added, when going into docked mode, or on window resize. If a diff was expanded or collapsed, the diff file index didn't know about this, and could present the wrong entries for the current view. We now use a `ResizeObserver` to track resizes to all the diffs, updating the extents whenever a resize is detected. To avoid duplicate calls to `updateLayout()` where this is computed (which could occur due to a window resize alone, or a window resize along with a `ResizeObserver` event), we now call a `queueUpdateLayout()` function, which will use `requestAnimationFrame()` to schedule `updateLayout()`. This, along with storing a request ID, prevents us from doing any unnecessary work that could lead to sluggish resizes.
    2f73b653b662ca07f738efdbc3d766b4b897310d
    maubin
    1. Ship It!
    2. 
        
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-6.x (eb76815)