(fix) O3-5408 : Form Builder crashes on creation of some forms#1082
(fix) O3-5408 : Form Builder crashes on creation of some forms#1082RajPrakash681 wants to merge 4 commits intoopenmrs:mainfrom
Conversation
Fixes crash and adds UI for person attribute selection.
|
@denniskigen please have a look at this |
| testOrder: TestOrderTypeQuestion, | ||
| }; | ||
|
|
||
| const PersonAttributeTypeQuestion: React.FC = () => { |
There was a problem hiding this comment.
This should be a component of its own, for example like this - https://github.com/openmrs/openmrs-esm-form-builder/blob/main/src/components/interactive-builder/modals/question/question-form/question-types/inputs/patient-identifier/patient-identifier-type-question.component.tsx, and then add it to this component map - https://github.com/openmrs/openmrs-esm-form-builder/blob/main/src/components/interactive-builder/modals/question/question-form/question-types/question-type.component.tsx
There was a problem hiding this comment.
This should be a component of its own, for example like this - https://github.com/openmrs/openmrs-esm-form-builder/blob/main/src/components/interactive-builder/modals/question/question-form/question-types/inputs/patient-identifier/patient-identifier-type-question.component.tsx, and then add it to this component map - https://github.com/openmrs/openmrs-esm-form-builder/blob/main/src/components/interactive-builder/modals/question/question-form/question-types/question-type.component.tsx
done !
|
|
||
| return ( | ||
| <div> | ||
| <FormLabel style={{ display: 'block', marginBottom: '0.5rem' }}> |
There was a problem hiding this comment.
Please avoid inline styling
| const handlePersonAttributeValidation = async (question, errors) => { | ||
| if (question.type === 'personAttribute' && !question.questionOptions.attributeType) { | ||
| errors.push({ | ||
| errorMessage: `❓ Person attribute type missing in schema`, |
There was a problem hiding this comment.
All these error messages should be translated
NethmiRodrigo
left a comment
There was a problem hiding this comment.
So a couple of things:
- In the recording in your PR description, when you select a person attribute type from the dropdown, the entire app refreshed and that definitely should not happen
- There’s something very wrong and I’m not sure what that is, but if you create a
personAttributetype question, it doesn’t render at all in the preview. Here is a sample question you can try. Maybe we need to fix this in the form engine itself? I’m not sure, but can you talk about this in #react-form-engine on Slack? - When you edit a
personAttributetype question, you’d see that the fields that you selected like theattributeTypearen’t populated. - There are some missing translation keys that haven’t been added to
en.json
ok so the app refreshing issue i have fixed will proceed accordingly! |
This commit fixes two critical issues with person attribute type questions: 1. App refresh on selection: Removed conflicting initialSelectedItem prop and added useEffect to properly sync selectedPersonAttributeType state when personAttributeTypes data loads asynchronously. 2. Fields not populated on edit: State now properly initializes to null and syncs via useEffect when data becomes available, ensuring the ComboBox displays the correct selected value when editing existing questions. Changes: - Added useEffect hook to sync state with async data - Removed initialSelectedItem from ComboBox (controlled component pattern) - Changed initial state from undefined to null for proper initialization - Added missing translation keys to en.json This addresses maintainer feedback about app refreshing and fields not populating when editing person attribute questions.
853a7ca to
00c053a
Compare
This commit fixes two critical issues with person attribute type questions: 1. App refresh on selection: Removed conflicting initialSelectedItem prop and added useEffect to properly sync selectedPersonAttributeType state when personAttributeTypes data loads asynchronously. 2. Fields not populated on edit: State now properly initializes to null and syncs via useEffect when data becomes available, ensuring the ComboBox displays the correct selected value when editing existing questions. Changes: - Added useEffect hook to sync state with async data - Removed initialSelectedItem from ComboBox (controlled component pattern) - Changed initial state from undefined to null for proper initialization - Added missing translation keys to en.json
Screen.Recording.2026-02-11.194257.mp4and about the rendering issue yes that's a problem i will ask that on slack and i think we need a separate ticket for that |
|
@NethmiRodrigo i asked ian about adding |
is it good to go as per the changes i made in order to fix the refreshing issue ? |
I think we should merge this in after your fix to the form-engine, the way I see it, there’s no point in the form builder supporting person attribute types if the form engine doesn’t. For now, what we should do is update the form builder so that it doesn’t crash for unsupported question types and just display a notification in the question modal saying that the form builder doesn’t support creating questions of this type. |
Requirements
Summary
This PR implements support for the personAttribute question type in the Form Builder and fixes a crash that occurred when selecting it. Previously, selecting this question type caused an application crash, and there was no UI to specific which person attribute type to use, leading to ambiguous "name name" errors.
video
Screen.Recording.2026-02-08.200601.mp4
Related Issue
https://issues.openmrs.org/browse/O3-5408
Other
NA