Skip to content

Commit e67fe67

Browse files
authored
#7225 Converting a Text question to the Email question type doesn't enable the "inputType": "email" option (#7227)
Fixes #7225
1 parent be74301 commit e67fe67

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

packages/survey-creator-core/src/creator-base.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4425,11 +4425,11 @@ export class SurveyCreatorModel extends Base
44254425
iconSize: "auto",
44264426
visible: item.visible,
44274427
enabled: item.enabled,
4428-
needSeparator: needSeparator
4428+
needSeparator: needSeparator,
4429+
action: () => {
4430+
onSelectQuestionType(item.typeName, item.json);
4431+
}
44294432
});
4430-
action.action = () => {
4431-
onSelectQuestionType(item.typeName, item.json);
4432-
};
44334433

44344434
if (!!item.items && item.items.length > 0 && this.toolbox.showSubitems) {
44354435
const innerItems = item.items.map(i => new Action({

packages/survey-creator-core/tests/question-adorner.tests.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QuestionAdornerViewModel } from "../src/components/question";
2-
import { Action, ComponentCollection, PopupDropdownViewModel, QuestionPanelDynamicModel, QuestionRadiogroupModel, settings, SurveyElement, SurveyModel, settings as surveySettings } from "survey-core";
2+
import { Action, ComponentCollection, PopupDropdownViewModel, QuestionPanelDynamicModel, QuestionRadiogroupModel, QuestionTextModel, settings, SurveyElement, SurveyModel, settings as surveySettings } from "survey-core";
33
import { CreatorTester } from "./creator-tester";
44
import { PageAdorner } from "../src/components/page";
55
import { TabDesignerPlugin } from "../src/components/tabs/designer-plugin";
@@ -929,6 +929,34 @@ test("Check question converter with subitems (types)", (): any => {
929929
surveySettings.animationEnabled = true;
930930
});
931931

932+
test("Check question converter on subitem search", (): any => {
933+
surveySettings.animationEnabled = false;
934+
const creator = new CreatorTester();
935+
936+
creator.JSON = {
937+
elements: [
938+
{ type: "text", name: "q1" },
939+
]
940+
};
941+
const question = creator.survey.getQuestionByName("q1");
942+
creator.selectElement(question);
943+
const questionAdorner = new QuestionAdornerViewModel(
944+
creator,
945+
question,
946+
<any>undefined
947+
);
948+
949+
const list = getQuestionConverterList(creator, "q1");
950+
list.filterString = "Email";
951+
const filteredActions = list.renderedActions.filter(item => list.isItemVisible(item));
952+
expect(filteredActions).toHaveLength(1);
953+
filteredActions[0].action();
954+
const questionConverted = creator.survey.getQuestionByName("q1") as QuestionTextModel;
955+
expect(questionConverted.inputType).toBe("email");
956+
957+
surveySettings.animationEnabled = true;
958+
});
959+
932960
test("Check question converter with single subitem (json)", (): any => {
933961
surveySettings.animationEnabled = false;
934962
const creator = new CreatorTester();

0 commit comments

Comments
 (0)