@@ -239,8 +239,13 @@ class Blocks extends React.Component {
239
239
updateToolbox ( ) {
240
240
this . toolboxUpdateTimeout = false ;
241
241
242
- // const categoryId = this.workspace.toolbox_.getSelectedItem().getId();
243
- // const offset = this.workspace.toolbox_.getCategoryScrollOffset();
242
+ const scale = this . workspace . getFlyout ( ) . getWorkspace ( ) . scale ;
243
+ const selectedCategoryName = this . workspace . getToolbox ( ) . getSelectedItem ( ) . getName ( ) ;
244
+ const selectedCategoryScrollPosition = this . workspace . getFlyout ( ) . getCategoryScrollPosition (
245
+ selectedCategoryName ) . y * scale ;
246
+ const offsetWithinCategory = ( this . workspace . getFlyout ( ) . getWorkspace ( ) . getMetrics ( ) . viewTop
247
+ - selectedCategoryScrollPosition ) ;
248
+
244
249
this . workspace . updateToolbox ( this . props . toolboxXML ) ;
245
250
this . workspace . refreshToolboxSelection ( ) ;
246
251
this . _renderedToolboxXML = this . props . toolboxXML ;
@@ -250,13 +255,10 @@ class Blocks extends React.Component {
250
255
// Using the setter function will rerender the entire toolbox which we just rendered.
251
256
this . workspace . toolboxRefreshEnabled_ = true ;
252
257
253
- // const currentCategoryPos = this.workspace.toolbox_.getCategoryPositionById(categoryId);
254
- // const currentCategoryLen = this.workspace.toolbox_.getCategoryLengthById(categoryId);
255
- // if (offset < currentCategoryLen) {
256
- // this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos + offset);
257
- // } else {
258
- // this.workspace.toolbox_.setFlyoutScrollPos(currentCategoryPos);
259
- // }
258
+ const newCategoryScrollPosition = this . workspace . getFlyout ( ) . getCategoryScrollPosition (
259
+ selectedCategoryName ) . y * scale ;
260
+ this . workspace . getFlyout ( ) . getWorkspace ( ) . scrollbar . setY (
261
+ newCategoryScrollPosition + offsetWithinCategory ) ;
260
262
261
263
const queue = this . toolboxUpdateQueue ;
262
264
this . toolboxUpdateQueue = [ ] ;
0 commit comments