From 6d1453082c3ed220c0ff09bf5b785a49df9f4312 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Wed, 18 Sep 2024 12:33:25 -0700 Subject: [PATCH] fix: fix positioning of categories when scrolling via the toolbox (#186) * fix: fix positioning of categories when scrolling via the toolbox * refactor: use GRID_UNIT for calculating flyout alignment --- src/checkable_continuous_flyout.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/checkable_continuous_flyout.js b/src/checkable_continuous_flyout.js index fb076aabc0..9d75cd53be 100644 --- a/src/checkable_continuous_flyout.js +++ b/src/checkable_continuous_flyout.js @@ -104,6 +104,26 @@ export class CheckableContinuousFlyout extends ContinuousFlyout { this.checkboxes_.clear(); } + layout_(contents, gaps) { + super.layout_(contents, gaps); + // We want large gaps between categories (see GAP_Y), but don't want those + // counted as part of the category for purposes of scrolling to show the + // category, so we reset/adjust the label gaps used for the scroll position + // calculation here. + this.labelGaps.fill( + this.getWorkspace().getRenderer().getConstants().GRID_UNIT + ); + } + + calculateBottomPadding(contentMetrics, viewMetrics) { + // Since we're messing with the alignment by munging the label gaps, we also + // need to adjust the bottom padding. + return ( + super.calculateBottomPadding(contentMetrics, viewMetrics) - + this.getWorkspace().getRenderer().getConstants().GRID_UNIT * 4 + ); + } + addBlockListeners_(root, block, rect) { if (block.checkboxInFlyout) { const coordinates = block.getRelativeToSurfaceXY();