Skip to content

Commit

Permalink
Flush any recursive layout work scheduled during an interaction
Browse files Browse the repository at this point in the history
This is an edge case, but it was causing e.g. the ResizableView's collapse/toggle to not properly update the display/size of the outermost scrollbar.
  • Loading branch information
Brian Vaughn committed Aug 10, 2021
1 parent 2dabbe7 commit 5dc8f02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/react-devtools-scheduling-profiler/src/CanvasPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ function AutoSizedCanvas({
const surface = surfaceRef.current;
surface.handleInteraction(interaction);

// Flush any display work that got queued up as part of the previous interaction.
// Typically there should be no work, but certain interactions may need a second pass.
// For example, the ResizableView may collapse/expand its contents,
// which requires a second layout pass for an ancestor VerticalScrollOverflowView.
surface.displayIfNeeded();

canvas.style.cursor = surface.getCurrentCursor() || 'default';

// Defer drawing to canvas until React's commit phase, to avoid drawing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ const withVerticalScrollbarLayout: Layouter = (layout, containerFrame) => {
return [laidOutContentLayoutInfo, laidOutScrollbarLayoutInfo];
};

// TODO How do we handle resizing
export class VerticalScrollOverflowView extends View {
_contentView: View;
_isProcessingOnChange: boolean = false;
Expand Down

0 comments on commit 5dc8f02

Please sign in to comment.