diff --git a/src/components/interactive-builder/modals/question/question-form/question/question.component.tsx b/src/components/interactive-builder/modals/question/question-form/question/question.component.tsx index 46f161fe..4750cf4a 100644 --- a/src/components/interactive-builder/modals/question/question-form/question/question.component.tsx +++ b/src/components/interactive-builder/modals/question/question-form/question/question.component.tsx @@ -5,6 +5,7 @@ import RenderTypeComponent from '../rendering-types/rendering-type.component'; import QuestionTypeComponent from '../question-types/question-type.component'; import RequiredLabel from '../common/required-label/required-label.component'; import { useFormField } from '../../form-field-context'; +import { cleanFormFieldForType } from '../../question-utils'; import type { FormField, RenderType } from '@openmrs/esm-form-engine-lib'; import { questionTypes, renderTypeOptions, renderingTypes } from '@constants'; import styles from './question.scss'; @@ -31,6 +32,15 @@ const Question: React.FC = ({ checkIfQuestionIdExists }) => { return checkIfQuestionIdExists(formField.id); }, [formField.id, checkIfQuestionIdExists]); + const handleQuestionTypeChange = useCallback( + (event: React.ChangeEvent) => { + const newType = event.target.value; + setFormField((prevFormField) => { + return cleanFormFieldForType({ ...prevFormField, type: newType }, newType); + }); + }, + [setFormField], + ); return ( <> = ({ checkIfQuestionIdExists }) => { )} required /> +