Skip to content

Commit 9718e7f

Browse files
authored
#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 640809a commit 9718e7f

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
@@ -565,6 +565,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
565565
const action = this.creator.createIActionBarItemByClass(item, needSeparator, (questionType, json) => { this.convertQuestion(questionType, json, defaultJsons); });
566566
if (this.toolboxItemIsCorresponded(item, !!selectedAction)) {
567567
selectedAction = action;
568+
selectedSubactions = item.items;
568569
}
569570
if (item.items?.length > 0 && this.creator.toolbox.showSubitems) {
570571
const subactions = [];
@@ -590,8 +591,8 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
590591
if (selectedSubactionLocal) {
591592
selectedAction = action;
592593
selectedSubaction = selectedSubactionLocal;
594+
selectedSubactions = subactions;
593595
}
594-
selectedSubactions = subactions;
595596
}
596597
lastItem = item;
597598
newItems.push(action);

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

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

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

0 commit comments

Comments
 (0)