Update the diff file index when diffs are expanded/collapsed.
Review Request #13235 — Created Aug. 23, 2023 and submitted
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
ResizeObserverto 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
ResizeObserverevent), we now call a
queueUpdateLayout()function, which will use
updateLayout(). This, along with storing a request ID,
prevents us from doing any unnecessary work that could lead to sluggish
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.