diff --git a/packages/survey-angular-ui/src/question.component.ts b/packages/survey-angular-ui/src/question.component.ts index 9a702a3f82..716ad2b2fb 100644 --- a/packages/survey-angular-ui/src/question.component.ts +++ b/packages/survey-angular-ui/src/question.component.ts @@ -2,6 +2,7 @@ import { Component, ElementRef, Input, ViewChild } from "@angular/core"; import { Question } from "survey-core"; import { AngularComponentFactory } from "./component-factory"; import { EmbeddedViewContentComponent } from "./embedded-view-content.component"; +import { getComponentName } from "./question"; @Component({ selector: "sv-ng-question", @@ -18,13 +19,7 @@ export class QuestionComponent extends EmbeddedViewContentComponent { this.model.afterRender(this.rootEl?.nativeElement); } } - public getComponentName(): string { - if (this.model.customWidget) return "survey-customwidget"; - if (this.model.isDefaultRendering()) { - return this.model.getTemplate() + "-question"; - } - return this.model.getComponentName(); - } + public getComponentName(): string { return getComponentName(this.model); } public getQuestionContentWrapperComponentName(): string { return (this.model.survey).getQuestionContentWrapperComponentName(this.model) || this.getComponentName(); } diff --git a/packages/survey-angular-ui/src/question.ts b/packages/survey-angular-ui/src/question.ts index 3df34bd224..dbcdc59995 100644 --- a/packages/survey-angular-ui/src/question.ts +++ b/packages/survey-angular-ui/src/question.ts @@ -25,4 +25,12 @@ export class QuestionAngular extends BaseAngular< } super.ngOnDestroy(); } +} + +export function getComponentName(question: Question): string { + if (question.customWidget) return "survey-customwidget"; + if (question.isDefaultRendering()) { + return question.getTemplate() + "-question"; + } + return question.getComponentName(); } \ No newline at end of file diff --git a/packages/survey-angular-ui/src/questions/custom.component.ts b/packages/survey-angular-ui/src/questions/custom.component.ts index 6e88b40020..e369147894 100644 --- a/packages/survey-angular-ui/src/questions/custom.component.ts +++ b/packages/survey-angular-ui/src/questions/custom.component.ts @@ -1,7 +1,7 @@ import { Question } from "survey-core"; import { QuestionCustomModel } from "survey-core"; import { Component } from "@angular/core"; -import { QuestionAngular } from "../question"; +import { QuestionAngular, getComponentName } from "../question"; import { AngularComponentFactory } from "../component-factory"; @Component({ @@ -12,12 +12,7 @@ export class CustomQuestionComponent extends QuestionAngular { @Input() question!: QuestionMatrixDropdownModelBase; @Input() cell!: QuestionMatrixDropdownRenderedCell; @@ -54,12 +55,7 @@ export class MatrixCellComponent extends BaseAngular { }; } - getComponentName(element: Question) { - if (element.customWidget) { - return "survey-customwidget"; - } - return element.getType()+"-question"; - } + getComponentName(element: Question) { return getComponentName(element); } getHeaders(): string { return this.cell.headers; } diff --git a/src/react/reactSurvey.tsx b/src/react/reactSurvey.tsx index 2cc3d2f407..88db173ddd 100644 --- a/src/react/reactSurvey.tsx +++ b/src/react/reactSurvey.tsx @@ -275,10 +275,7 @@ export class Survey extends SurveyElementBase //ISurveyCreator public createQuestionElement(question: Question): JSX.Element | null { - return ReactQuestionFactory.Instance.createQuestion( - !question.isDefaultRendering || question.isDefaultRendering() - ? question.getTemplate() - : question.getComponentName(), + return ReactQuestionFactory.Instance.createQuestion(question.isDefaultRendering() ? question.getTemplate() : question.getComponentName(), { question: question, isDisplayMode: question.isInputReadOnly, diff --git a/src/vue/custom.vue b/src/vue/custom.vue index 79c12617f1..0c345f113b 100644 --- a/src/vue/custom.vue +++ b/src/vue/custom.vue @@ -9,7 +9,7 @@