Skip to content

Commit

Permalink
Passed fallback rootElement
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Sep 27, 2024
1 parent f487572 commit 88ec6ec
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5261,10 +5261,9 @@ export class SurveyModel extends SurveyElementCore
public skeletonHeight: number = undefined;

scrollElementToTop(
element: ISurveyElement,
question: Question,
page: PageModel,
id: string, scrollIfVisible?: boolean, scrollIntoViewOptions?: ScrollIntoViewOptions
element: ISurveyElement, question: Question, page: PageModel,
id: string, scrollIfVisible?: boolean, scrollIntoViewOptions?: ScrollIntoViewOptions,
passedRootElement?: HTMLElement
): any {
const options: ScrollingElementToTopEvent = {
element: element,
Expand All @@ -5278,8 +5277,10 @@ export class SurveyModel extends SurveyElementCore
const elementPage = this.getPageByElement(element as IElement);
if (this.isLazyRendering) {
let elementsToRenderBefore = 1;
if (!!this.skeletonHeight && !!this.rootElement && typeof this.rootElement.getBoundingClientRect === "function") {
elementsToRenderBefore = this.rootElement.getBoundingClientRect().height / this.skeletonHeight - 1;
const { rootElement } = settings.environment;
const surveyRootElement = this.rootElement || passedRootElement || rootElement as any;
if (!!this.skeletonHeight && !!surveyRootElement && typeof surveyRootElement.getBoundingClientRect === "function") {
elementsToRenderBefore = surveyRootElement.getBoundingClientRect().height / this.skeletonHeight - 1;
}
elementPage.forceRenderElement(element as IElement, () => {
this.suspendLazyRendering();
Expand Down

0 comments on commit 88ec6ec

Please sign in to comment.