@@ -541,6 +541,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
541
541
element . closest ( ".svc-question__drag-area" ) && ! element . closest ( ".svc-question__top-actions" ) ||
542
542
element . closest ( ".sd-element__header" ) && ! element . closest ( ".svc-string-editor" ) ;
543
543
}
544
+
544
545
protected updateQuestionTypeOrSubtypeListModel ( listModel : ListModel , subtypeOnly : boolean ) {
545
546
const availableItems = this . getConvertToTypes ( ) ;
546
547
const defaultJsons = this . buildDefaultJsonMap ( availableItems ) ;
@@ -549,25 +550,32 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
549
550
let selectedAction : IAction ;
550
551
let selectedSubaction : IAction = undefined ;
551
552
let selectedSubactions = undefined ;
553
+
554
+ const toolboxItemToAction = ( item , needSeparator = false ) => {
555
+ return this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
556
+ } ;
557
+
552
558
availableItems . forEach ( ( item : QuestionToolboxItem ) => {
553
559
const needSeparator = lastItem && item . category != lastItem . category ;
554
- const action = this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
560
+ const action = toolboxItemToAction ( item , needSeparator ) ;
555
561
if ( this . toolboxItemIsCorresponded ( item , ! ! selectedAction ) ) {
556
562
selectedAction = action ;
557
- selectedSubactions = item . items ;
563
+ if ( item . items ) {
564
+ selectedSubactions = item . items . map ( subitem => toolboxItemToAction ( subitem ) ) ;
565
+ }
558
566
}
559
567
if ( item . items ?. length > 0 && this . creator . toolbox . showSubitems ) {
560
568
const subactions = [ ] ;
561
569
let selectedSubactionLocal : IAction = undefined ;
562
570
let allChildsAreCompatibleToParent = false ;
563
571
item . items . forEach ( subitem => {
564
- const subaction = this . creator . createIActionBarItemByClass ( subitem , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
572
+ const subaction = toolboxItemToAction ( subitem , ) ;
565
573
if ( this . toolboxItemIsCorresponded ( subitem , ! ! selectedAction ) ) selectedSubactionLocal = subitem ;
566
574
if ( this . jsonsAreCompatible ( item . json , subitem . json ) ) allChildsAreCompatibleToParent = true ;
567
575
subactions . push ( subaction ) ;
568
576
} ) ;
569
577
if ( ! allChildsAreCompatibleToParent && subactions . length > 0 ) {
570
- const defaultSubaction = this . creator . createIActionBarItemByClass ( item , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
578
+ const defaultSubaction = toolboxItemToAction ( item ) ;
571
579
defaultSubaction . id = action . id + "-default" ;
572
580
defaultSubaction . iconName = undefined ;
573
581
defaultSubaction . markerIconName = undefined ;
0 commit comments