Skip to content

Commit 2e1bb35

Browse files
committed
#6692 Toolbox subitems: Subitem dropdown contains incorrect subitems (#6693)
* #6692 Toolbox subitems: Subitem dropdown contains incorrect subitems Fixes #6692 * add unit test, #6692
1 parent 5110781 commit 2e1bb35

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/survey-creator-core/src/components/question.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
570570
const action = this.creator.createIActionBarItemByClass(item, needSeparator, (questionType, json) => { this.convertQuestion(questionType, json, defaultJsons); });
571571
if (this.toolboxItemIsCorresponded(item, !!selectedAction)) {
572572
selectedAction = action;
573+
selectedSubactions = item.items;
573574
}
574575
if (item.items?.length > 0 && this.creator.toolbox.showSubitems) {
575576
const subactions = [];
@@ -595,8 +596,8 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
595596
if (selectedSubactionLocal) {
596597
selectedAction = action;
597598
selectedSubaction = selectedSubactionLocal;
599+
selectedSubactions = subactions;
598600
}
599-
selectedSubactions = subactions;
600601
}
601602
lastItem = item;
602603
newItems.push(action);

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

+23
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ test("Check question adorners popups display mode", (): any => {
6666
expect(convertToAction.popupModel.displayMode).toBe("overlay");
6767
});
6868

69+
test("Check rating question input type list", (): any => {
70+
const creator = new CreatorTester();
71+
creator.JSON = {
72+
elements: [
73+
{ type: "rating", name: "q1" },
74+
]
75+
};
76+
const question = creator.survey.getQuestionByName("q1");
77+
let questionAdorner = new QuestionAdornerViewModel(
78+
creator,
79+
question,
80+
<any>undefined
81+
);
82+
83+
let convertInputTypeAction = questionAdorner.actionContainer.getActionById("convertInputType");
84+
const popup = convertInputTypeAction.popupModel;
85+
const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow
86+
popup.show();
87+
const list = popup.contentComponentData.model;
88+
89+
expect(list.actions.map(i => i.id)).toEqual(["labels", "stars", "smileys"]);
90+
});
91+
6992
test("Check question converter with removed subitems", (): any => {
7093
surveySettings.animationEnabled = false;
7194
const creator = new CreatorTester();

0 commit comments

Comments
 (0)