diff --git a/packages/survey-creator-core/src/components/question.ts b/packages/survey-creator-core/src/components/question.ts index 5a5978be50..61f393e889 100644 --- a/packages/survey-creator-core/src/components/question.ts +++ b/packages/survey-creator-core/src/components/question.ts @@ -198,6 +198,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase { private createCustomMessagePanel(): QuestionBannerParams { if (!this.isMessagePanelVisible) return null; const res: any = { + question: this.element, actionText: "", messageText: "", onClick: () => { } diff --git a/packages/survey-creator-core/tests/creator-base.tests.ts b/packages/survey-creator-core/tests/creator-base.tests.ts index 2671839035..9f1303dbba 100644 --- a/packages/survey-creator-core/tests/creator-base.tests.ts +++ b/packages/survey-creator-core/tests/creator-base.tests.ts @@ -3549,11 +3549,13 @@ test("Custom messagePanel", (): any => { } }); const creator = new CreatorTester(); + let questionName; creator.onCreateCustomMessagePanel.add((sender, options) => { options.messageText = "Banner text#"; options.actionText = "Action text#"; + questionName = options.question.name; options.onClick = () => { - creator.selectElement(creator.survey.getQuestionByName("q2"), "prop1"); + creator.selectElement(options.question, "prop1"); }; }); creator.JSON = { @@ -3569,11 +3571,12 @@ test("Custom messagePanel", (): any => { q1.prop1 = 1; expect(q1AdornerModel.isBannerShowing).toBeTruthy(); const bannerParams = q1AdornerModel.createBannerParams(); + expect(questionName).toBe("q1"); expect(bannerParams.text).toBe("Banner text#"); expect(bannerParams.actionText).toBe("Action text#"); expect(creator.selectedElementName).toBe("survey"); bannerParams.onClick(); - expect(creator.selectedElementName).toBe("q2"); + expect(creator.selectedElementName).toBe("q1"); q1.prop1 = 0; expect(q1AdornerModel.isBannerShowing).toBeFalsy(); Serializer.removeProperty("selectbase", "prop1");