Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specialized Question Types - The question.isDesignMode doesn't return the actual value #8767

Open
JaneSjs opened this issue Sep 3, 2024 · 0 comments · May be fixed by #8931
Open

Specialized Question Types - The question.isDesignMode doesn't return the actual value #8767

JaneSjs opened this issue Sep 3, 2024 · 0 comments · May be fixed by #8931
Assignees
Labels

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented Sep 3, 2024

T19649 - Custom components, in read-only mode, I cannot set default values.
https://surveyjs.answerdesk.io/internal/ticket/details/T19649


View Demo
Task: to allow users to edit a specialized question and set its default value at design time, however, disable the question in preview.

I thought that I can use the question.isDesignMode setting to check whether or not a question is in design mode. However, the question.isDesignMode returns false within the onCreated, onLoaded, onAfterRender functions. The question.isDesignMode only returns true in onAfterRenderQuestion event for the first time. When you click the Default Value editor, the isDesignMode again returns false.
image

Therefore, I cannot conditionally enable or disable a specialized question type using the ICustomQuestionTypeConfiguration and Question API. As an option, I can enable the readOnly option when a SurveyModel is initialized.

const allQuestions = options.survey.getAllQuestions();
allQuestions.forEach(q => {
     if(q.getType() === "triggerworkflow"){
          q.readOnly = true;
    }
})

However, I though that I would implement the required business logic at the level of my custom component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants