diff --git a/packages/survey-core/src/survey-events-api.ts b/packages/survey-core/src/survey-events-api.ts index b443333d61..2b137cb1bd 100644 --- a/packages/survey-core/src/survey-events-api.ts +++ b/packages/survey-core/src/survey-events-api.ts @@ -208,12 +208,12 @@ export interface CurrentPageChangedEvent { * The current question.\ * This parameter has a value only in [question-per-page mode](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#questionsOnPageMode). */ - oldCurrentQuestion?: Question; + oldCurrentQuestion?: Question | PanelModel; /** * A question that used to be current.\ * This parameter has a value only in [question-per-page mode](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#questionsOnPageMode). */ - newCurrentQuestion?: Question; + newCurrentQuestion?: Question | PanelModel; } export interface CurrentPageChangingEvent extends CurrentPageChangedEvent { /** diff --git a/packages/survey-core/src/survey.ts b/packages/survey-core/src/survey.ts index dd71c9eb77..2b3090dd46 100644 --- a/packages/survey-core/src/survey.ts +++ b/packages/survey-core/src/survey.ts @@ -4713,7 +4713,7 @@ export class SurveyModel extends SurveyElementCore }); this.updateButtonsVisibility(); } - private currentSingleElementValue: IElement; + private currentSingleElementValue: IElement | undefined; private getSingleElements(includeEl?: IElement): Array { const res = new Array(); const pages = this.pages; @@ -4727,10 +4727,10 @@ export class SurveyModel extends SurveyElementCore } return res; } - public get currentSingleElement(): IElement { + public get currentSingleElement(): IElement | undefined { return !this.isShowingPreview ? this.currentSingleElementValue : undefined; } - public set currentSingleElement(val: IElement) { + public set currentSingleElement(val: IElement | undefined) { const oldVal = this.currentSingleElement; if(val !== oldVal && !this.isCompleted) { const valQuestion = val?.isQuestion ? val : undefined; @@ -4757,12 +4757,11 @@ export class SurveyModel extends SurveyElementCore } } } - public get currentSingleQuestion(): Question { - const res = this.currentSingleElement; - return !!res && res.isQuestion ? res : undefined; + public get currentSingleQuestion(): Question | IPanel { + return this.currentSingleElement; } - public set currentSingleQuestion(val: Question) { - this.currentSingleElement = val; + public set currentSingleQuestion(val: Question | IPanel) { + this.currentSingleElement = val; } private changeCurrentSingleElementOnVisibilityChanged(): void { const el = this.currentSingleElement;