Hi SurveyJS Team,
we managed to implement a custom feature using the official SurveyJS documentation and we want to hide it behind a feature flag.
Just for clarity, we have decided to register a new boolean value in the property grid for questions of type radio group, adding the possibility to hide the input circles and mark the selected item with a colored border. This feature required interfering with multiple parts of the library.
First, we had to register the new property in the grid, this is done globally on the Survey module:
TypeScriptimport * as Survey from 'survey-core';
Survey.Serializer.addProperties('question', [
{
name: 'hideChoiceInput',
type: 'boolean',
category: 'choices',
},
]);
Second, we had to register callbacks for each survey model instance, after it was created with the new keyword, and make sure that it is called whenever we are working with Survey Creator or Survey Viewer:
TypeScriptimport { Model } from 'survey-react';
const survey = new Model();
survey.onAfterRenderQuestion.add(restyleChoiceQuestions);
survey.onAfterRenderMatrixCell.add(restyleChoiceQuestions);
Was our approach correct? Is there a way to register these mechanisms in a single step, perhaps by registering the lifecycle hook callbacks globally? Is there a way to create an "universal plugin" for SurveyJS, which can be registered in one place for Creator and Viewer, globally or locally for all the required mechanisms?
Thank you all in advance!