Skip to content

Commit

Permalink
fix: improve flyout performance
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Sep 11, 2024
1 parent cb1c055 commit 5883c8d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions core/flyout_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,14 @@ export abstract class Flyout
this.wheel_,
),
);
this.filterWrapper = this.filterForCapacity.bind(this);
this.filterWrapper = (event) => {
if (
event.type === eventUtils.BLOCK_CREATE ||
event.type === eventUtils.BLOCK_DELETE
) {
this.filterForCapacity();
}
};
this.targetWorkspace.addChangeListener(this.filterWrapper);

// Dragging the flyout up and down.
Expand Down Expand Up @@ -707,7 +714,17 @@ export abstract class Flyout
// Correctly position the flyout's scrollbar when it opens.
this.position();

this.reflowWrapper = this.reflow.bind(this);
// Listen for block change events, and reflow the flyout in response. This
// accommodates e.g. resizing a non-autoclosing flyout in response to the
// user typing long strings into fields on the blocks in the flyout.
this.reflowWrapper = (event) => {
if (
event.type === eventUtils.BLOCK_CHANGE ||
event.type === eventUtils.BLOCK_FIELD_INTERMEDIATE_CHANGE
) {
this.reflow();
}
};
this.workspace_.addChangeListener(this.reflowWrapper);
this.emptyRecycledBlocks();
}
Expand Down

0 comments on commit 5883c8d

Please sign in to comment.