Skip to content

(fix) O3-4613 Choosing a default radio button "type of date picker to show" radio group #446

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 5 commits into
base: main
Choose a base branch
from

Conversation

yoursanonymous
Copy link

@yoursanonymous yoursanonymous commented Apr 8, 2025

…roup button

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

When we create a question of type "encounterDateTime", we have radio buttons of "type of date picker to show" should be selected when we save a form but, it's not working.

Screenshots

Before

beforeSave.mp4

After

afterSave.mp4

Related Issue

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

Other

@atulyadav745
Copy link
Contributor

Thanks @yoursanonymous, great catch! Really appreciate you pointing this out.

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.

I don't think its really necessary to default pick a datepicker type for this, but if we are doing it, its much better to set it here when the rendering type is being set rather than use an useEffect-

.
We should avoid the usage of useEffects wherever we can - https://react.dev/learn/you-might-not-need-an-effect

@yoursanonymous yoursanonymous changed the title O3-4613 Choosing a default radio button "type of date picker to show" radio group (fix) O3-4613 Choosing a default radio button "type of date picker to show" radio group Apr 9, 2025
@yoursanonymous
Copy link
Author

yoursanonymous commented Apr 9, 2025

Hi @NethmiRodrigo, Thank you for reviewing my PR,
Sorry just realized by looking at a similar 'ui-select-extended' component that using 'defaultSelected' property of RadioButtonGroup would be a better way to set the default value for Date picker type, made the required changes as well.

Could you please review it again.

@@ -25,7 +25,7 @@ const Date: React.FC = () => {
);

return (
<RadioButtonGroup name="datePickerType" legendText={t('datePickerType', 'The type of date picker to show ')}>
<RadioButtonGroup name="datePickerType" defaultSelected="both" legendText={t('datePickerType', 'The type of date picker to show ')}>
Copy link
Collaborator

@NethmiRodrigo NethmiRodrigo Apr 10, 2025

Choose a reason for hiding this comment

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

using 'defaultSelected' property of RadioButtonGroup would be a better way to set the default value for Date picker type, made the required changes as well.

Using the defaultSelected that would mean that the user gets the impression that when they save the defaultSelected value would be persisted, but that isn't the case here. To fix that, referring back to my first suggestion, you'd have to set the datePickerFormat in the formField while using the defaultSelected here

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