Skip to content

Commit b8f19dc

Browse files
authored
fix: fix preserving toolbox scroll position for new continuous toolbox plugin (#30)
1 parent 67a5e05 commit b8f19dc

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/containers/blocks.jsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,27 +316,28 @@ class Blocks extends React.Component {
316316
const selectedCategoryScrollPosition =
317317
this.workspace
318318
.getFlyout()
319-
.getCategoryScrollPosition(selectedCategoryName).y * scale;
319+
.getCategoryScrollPosition(selectedCategoryName) * scale;
320320
const offsetWithinCategory =
321321
this.workspace.getFlyout().getWorkspace().getMetrics().viewTop -
322322
selectedCategoryScrollPosition;
323323

324324
this.workspace.updateToolbox(this.props.toolboxXML);
325+
this.workspace.getToolbox().runAfterRerender(() => {
326+
const newCategoryScrollPosition = this.workspace
327+
.getFlyout()
328+
.getCategoryScrollPosition(selectedCategoryName);
329+
if (newCategoryScrollPosition) {
330+
this.workspace
331+
.getFlyout()
332+
.getWorkspace()
333+
.scrollbar.setY(
334+
newCategoryScrollPosition * scale + offsetWithinCategory
335+
);
336+
}
337+
});
325338
this.workspace.getToolbox().forceRerender();
326339
this._renderedToolboxXML = this.props.toolboxXML;
327340

328-
const newCategoryScrollPosition = this.workspace
329-
.getFlyout()
330-
.getCategoryScrollPosition(selectedCategoryName);
331-
if (newCategoryScrollPosition) {
332-
this.workspace
333-
.getFlyout()
334-
.getWorkspace()
335-
.scrollbar.setY(
336-
newCategoryScrollPosition.y * scale + offsetWithinCategory
337-
);
338-
}
339-
340341
const queue = this.toolboxUpdateQueue;
341342
this.toolboxUpdateQueue = [];
342343
queue.forEach((fn) => fn());

0 commit comments

Comments
 (0)