Skip to content

Commit 6d14530

Browse files
authored
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
1 parent 6c9d3a6 commit 6d14530

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/checkable_continuous_flyout.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ export class CheckableContinuousFlyout extends ContinuousFlyout {
104104
this.checkboxes_.clear();
105105
}
106106

107+
layout_(contents, gaps) {
108+
super.layout_(contents, gaps);
109+
// We want large gaps between categories (see GAP_Y), but don't want those
110+
// counted as part of the category for purposes of scrolling to show the
111+
// category, so we reset/adjust the label gaps used for the scroll position
112+
// calculation here.
113+
this.labelGaps.fill(
114+
this.getWorkspace().getRenderer().getConstants().GRID_UNIT
115+
);
116+
}
117+
118+
calculateBottomPadding(contentMetrics, viewMetrics) {
119+
// Since we're messing with the alignment by munging the label gaps, we also
120+
// need to adjust the bottom padding.
121+
return (
122+
super.calculateBottomPadding(contentMetrics, viewMetrics) -
123+
this.getWorkspace().getRenderer().getConstants().GRID_UNIT * 4
124+
);
125+
}
126+
107127
addBlockListeners_(root, block, rect) {
108128
if (block.checkboxInFlyout) {
109129
const coordinates = block.getRelativeToSurfaceXY();

0 commit comments

Comments
 (0)