@@ -557,6 +557,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
557
557
element . closest ( ".svc-question__drag-area" ) && ! element . closest ( ".svc-question__top-actions" ) ||
558
558
element . closest ( ".sd-element__header" ) && ! element . closest ( ".svc-string-editor" ) ;
559
559
}
560
+
560
561
protected updateQuestionTypeOrSubtypeListModel ( listModel : ListModel , subtypeOnly : boolean ) {
561
562
const availableItems = this . getConvertToTypes ( ) ;
562
563
const defaultJsons = this . buildDefaultJsonMap ( availableItems ) ;
@@ -565,25 +566,32 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
565
566
let selectedAction : IAction ;
566
567
let selectedSubaction : IAction = undefined ;
567
568
let selectedSubactions = undefined ;
569
+
570
+ const toolboxItemToAction = ( item , needSeparator = false ) => {
571
+ return this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
572
+ } ;
573
+
568
574
availableItems . forEach ( ( item : QuestionToolboxItem ) => {
569
575
const needSeparator = lastItem && item . category != lastItem . category ;
570
- const action = this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
576
+ const action = toolboxItemToAction ( item , needSeparator ) ;
571
577
if ( this . toolboxItemIsCorresponded ( item , ! ! selectedAction ) ) {
572
578
selectedAction = action ;
573
- selectedSubactions = item . items ;
579
+ if ( item . items ) {
580
+ selectedSubactions = item . items . map ( subitem => toolboxItemToAction ( subitem ) ) ;
581
+ }
574
582
}
575
583
if ( item . items ?. length > 0 && this . creator . toolbox . showSubitems ) {
576
584
const subactions = [ ] ;
577
585
let selectedSubactionLocal : IAction = undefined ;
578
586
let allChildsAreCompatibleToParent = false ;
579
587
item . items . forEach ( subitem => {
580
- const subaction = this . creator . createIActionBarItemByClass ( subitem , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
588
+ const subaction = toolboxItemToAction ( subitem , ) ;
581
589
if ( this . toolboxItemIsCorresponded ( subitem , ! ! selectedAction ) ) selectedSubactionLocal = subitem ;
582
590
if ( this . jsonsAreCompatible ( item . json , subitem . json ) ) allChildsAreCompatibleToParent = true ;
583
591
subactions . push ( subaction ) ;
584
592
} ) ;
585
593
if ( ! allChildsAreCompatibleToParent && subactions . length > 0 ) {
586
- const defaultSubaction = this . creator . createIActionBarItemByClass ( item , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
594
+ const defaultSubaction = toolboxItemToAction ( item ) ;
587
595
defaultSubaction . id = action . id + "-default" ;
588
596
defaultSubaction . iconName = undefined ;
589
597
defaultSubaction . markerIconName = undefined ;
0 commit comments