Skip to content

Commit

Permalink
Add question into onCreateCustomMessagePanel event
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jan 16, 2024
1 parent 4fabf4a commit 179c9c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/survey-creator-core/src/components/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => { }
Expand Down
7 changes: 5 additions & 2 deletions packages/survey-creator-core/tests/creator-base.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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");
Expand Down

0 comments on commit 179c9c3

Please sign in to comment.