Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(fix) O3-3634: DatePicker input should clear when unspecified is checked #354

Closed
wants to merge 4 commits into from

Conversation

ODORA0
Copy link
Member

@ODORA0 ODORA0 commented Jul 24, 2024

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

Screenshots

Screen.Recording.2024-07-24.at.11.38.06.mov

Related Issue

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

Other

@ODORA0 ODORA0 requested a review from arodidev July 24, 2024 08:41
@@ -97,6 +107,7 @@ const DateField: React.FC<FormFieldProps> = ({ question, onChange, handler, prev
<div className={styles.datePickerSpacing}>
<Layer>
<OpenmrsDatePicker
key={key}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the field id as the key instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@arodidev When using a dynamic key like field.value, the component may not behave as expected in some cases. So using the original approach which also ensure the component updates correctly when unspecified is check works well with tests as well

Copy link
Contributor

Choose a reason for hiding this comment

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

The question id is not dynamic, and would be much more suited rather than the int here

Copy link
Member Author

Choose a reason for hiding this comment

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

The major issue is with how the OpenmrsDatePicker propagates the states from the main component to the DatePickerInput component in esm core, when the value is cleared it never trickles down cc @samuelmale
We can report this bug but doing this as well will also re-render the component thus clearing the input when unspecified is check

Copy link
Member

Choose a reason for hiding this comment

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

@ibacher any thoughts on the above?

Copy link
Member

Choose a reason for hiding this comment

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

This should be fixed.

@samuelmale
Copy link
Member

@ODORA0 did you see the CI failure?

if (unspecifiedField.value) {
setFieldValue(question.id, null);
setTime(null);
setKey(prevKey => prevKey + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we use an int as key as increment it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -97,6 +107,7 @@ const DateField: React.FC<FormFieldProps> = ({ question, onChange, handler, prev
<div className={styles.datePickerSpacing}>
<Layer>
<OpenmrsDatePicker
key={key}
Copy link
Contributor

Choose a reason for hiding this comment

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

The question id is not dynamic, and would be much more suited rather than the int here

@brandones brandones changed the title (Fix) DatePicker input should clear when unspecified is checked (fix) O3-3634: DatePicker input should clear when unspecified is checked Aug 5, 2024
@brandones
Copy link
Contributor

@ODORA0 @samuelmale @NethmiRodrigo Is it clear what needs to happen before we can put this in? I've fixed the merge conflicts. Looks like CI is passing. Can someone please file a ticket for the bug where the datepicker doesn't update when its value is cleared?

@NethmiRodrigo
Copy link
Contributor

NethmiRodrigo commented Aug 5, 2024

@ODORA0 @brandones I think we might need to change the whole updating the id to force re-render following the fix that @ibacher made in this PR. I made a separate PR to update the datepicker but trying to get the tests fixed before that

@brandones
Copy link
Contributor

@NethmiRodrigo does that PR supersede this one? If so please close this PR and link O3-3634 to your PR.

@NethmiRodrigo
Copy link
Contributor

NethmiRodrigo commented Aug 5, 2024

@brandones doesn't exactly supersede, I just updated the onChange function (updated a prop), but I could bundle in the fix for this in that PR

@brandones
Copy link
Contributor

@NethmiRodrigo if the solution in this PR will still be the right solution, then just merge yours and then we'll merge this PR. If this PR no longer has anything useful about it, just add the solution to your PR and close this one.

@brandones
Copy link
Contributor

(or open a new PR, however you like)

@samuelmale
Copy link
Member

Closing this because it was addressed here.

@samuelmale samuelmale closed this Aug 8, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants