{"record":{"id":"f70531f60a234ec1","repo":"angular/components","slug":"cdk-virtual-scroll-scrolltoindex-is-currently-not","errorCode":null,"errorMessage":"cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize scroll strategy","messagePattern":"cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize scroll strategy","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts","lineNumber":171,"sourceCode":"  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onContentRendered() {\n    if (this._viewport) {\n      this._checkRenderedContentSize();\n    }\n  }\n\n  /** @docs-private Implemented as part of VirtualScrollStrategy. */\n  onRenderedOffsetChanged() {\n    if (this._viewport) {\n      this._checkRenderedContentOffset();\n    }\n  }\n\n  /** Scroll to the offset for the given index. */\n  scrollToIndex(): void {\n    if (typeof ngDevMode === 'undefined' || ngDevMode) {\n      // TODO(mmalerba): Implement.\n      throw Error(\n        'cdk-virtual-scroll: scrollToIndex is currently not supported for the autosize' +\n          ' scroll strategy',\n      );\n    }\n  }\n\n  /**\n   * Update the buffer parameters.\n   * @param minBufferPx The minimum amount of buffer rendered beyond the viewport (in pixels).\n   * @param maxBufferPx The number of buffer items to render beyond the edge of the viewport (in\n   *     pixels).\n   */\n  updateBufferSize(minBufferPx: number, maxBufferPx: number) {\n    if (maxBufferPx < minBufferPx) {\n      throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n    }\n    this._minBufferPx = minBufferPx;\n    this._maxBufferPx = maxBufferPx;","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts#L153-L189","documentation":"AutoSizeVirtualScrollStrategy also does not implement scrollToIndex; calling it throws this error in dev mode. The method is required by the VirtualScrollStrategy interface but remains a TODO in the experimental autosize strategy. Production builds silently do nothing.","triggerScenarios":"Calling CdkVirtualScrollViewport.scrollToIndex() (or scrollToOffset, which delegates per strategy) when the viewport uses AutoSizeVirtualScrollStrategy in a development build.","commonSituations":"Programmatic scrolling: jumping to a saved scroll position, scroll-to-top buttons, navigating back to a list and restoring position; code that worked with fixed-size strategy moved to autosize.","solutions":["Scroll the viewport's native element manually: viewport.elementRef.nativeElement.scrollTop = offset, using an offset you track yourself.","Switch to a strategy that supports scrollToIndex (fixed-size itemSize or the non-experimental variable-size strategy).","Avoid programmatic index-based scrolling with autosize until the TODO is implemented upstream."],"exampleFix":"// before\nviewport.scrollToIndex(targetIndex); // throws with autosize\n// after\nviewport.elementRef.nativeElement.scrollTop = savedPixelOffset;","handlingStrategy":"validation","validationCode":"if (viewport.strategy instanceof AutoSizeVirtualScrollStrategy) {\n  // scrollToIndex unsupported; set scrollTop manually instead\n  viewport.elementRef.nativeElement.scrollTop = targetOffset;\n} else {\n  viewport.scrollToIndex(targetIndex);\n}","typeGuard":null,"tryCatchPattern":"try {\n  viewport.scrollToIndex(i);\n} catch {\n  viewport.elementRef.nativeElement.scrollTop = savedOffsetForIndex(i);\n}","preventionTips":["Avoid programmatic index-based scrolling with the autosize experimental strategy.","Persist scroll offsets in pixels, not indices, when restoring positions with autosize.","Prefer stable strategies (fixed-size/variable-size) when you need scrollToIndex."],"tags":["angular","cdk","virtual-scroll","experimental","unsupported-feature"],"backgroundTag":"unimplemented-experimental-api","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}