Skip to content

Commit def80b3

Browse files
authored
fix: improve flyout performance (#8571)
* fix: improve flyout performance * refactor: don't call position() in show() The later call to reflow() itself winds up calling position(), so this calculation is redundant.
1 parent cb1c055 commit def80b3

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

core/flyout_base.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,14 @@ export abstract class Flyout
402402
this.wheel_,
403403
),
404404
);
405-
this.filterWrapper = this.filterForCapacity.bind(this);
405+
this.filterWrapper = (event) => {
406+
if (
407+
event.type === eventUtils.BLOCK_CREATE ||
408+
event.type === eventUtils.BLOCK_DELETE
409+
) {
410+
this.filterForCapacity();
411+
}
412+
};
406413
this.targetWorkspace.addChangeListener(this.filterWrapper);
407414

408415
// Dragging the flyout up and down.
@@ -704,10 +711,17 @@ export abstract class Flyout
704711

705712
this.filterForCapacity();
706713

707-
// Correctly position the flyout's scrollbar when it opens.
708-
this.position();
709-
710-
this.reflowWrapper = this.reflow.bind(this);
714+
// Listen for block change events, and reflow the flyout in response. This
715+
// accommodates e.g. resizing a non-autoclosing flyout in response to the
716+
// user typing long strings into fields on the blocks in the flyout.
717+
this.reflowWrapper = (event) => {
718+
if (
719+
event.type === eventUtils.BLOCK_CHANGE ||
720+
event.type === eventUtils.BLOCK_FIELD_INTERMEDIATE_CHANGE
721+
) {
722+
this.reflow();
723+
}
724+
};
711725
this.workspace_.addChangeListener(this.reflowWrapper);
712726
this.emptyRecycledBlocks();
713727
}

0 commit comments

Comments
 (0)