Skip to content

(fix) O3-4581: Reset the rendering type when the question type changes #426

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

yoursanonymous
Copy link

@yoursanonymous yoursanonymous commented Mar 30, 2025

Added logic to remove rendering type value if the previously selected rendering type value is not present for the new question type

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Rendering type was same even after changing the Question type and in UI it selects the 1st dropdown value if previous selected rendering type is not available

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-4581

Other

Added logic to remove rendering type value if the previously selected rendering type value is not present for the new question type
Copy link

@Pratibha0280 Pratibha0280 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @yoursanonymous , I noticed that the code directly mutates the formField object using the delete operator.
Instead, I would suggest to create a new object without the questionOptions property when needed. This way, the state updates cleanly and predictably.

Copy link
Collaborator

@NethmiRodrigo NethmiRodrigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yoursanonymous, please include a screen recording of before and after the fix

1. Added a separate function to handle formField change
2. Removed directly deleting line to avoid directly mutating the formField object
@yoursanonymous
Copy link
Author

we can see that the rendering type was automatically selected as the first dropdown value

before.mp4

now we can see that it is asking us to choose a rendering type instead of automatically selecting first drop down value after we changed the question type

after.mp4

@NethmiRodrigo NethmiRodrigo changed the title (fix) O3-4581 Choose a rendering type fixed for question type change (fix) O3-4581: Change the rendering type to a valid value when changing the question type Apr 4, 2025
@NethmiRodrigo NethmiRodrigo changed the title (fix) O3-4581: Change the rendering type to a valid value when changing the question type (fix) O3-4581: Reset the rendering type when the question type changes Apr 4, 2025
@yoursanonymous
Copy link
Author

Hi @NethmiRodrigo , Thankyou for approving my PR,
Is it alright to merge it now?

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

Successfully merging this pull request may close these issues.

3 participants