Skip to content
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

(feat) O3-3608: Adjust step precision for the dose field in the DrugOrder form #1911

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

its-kios09
Copy link
Contributor

@its-kios09 its-kios09 commented Jul 12, 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

medication

Related Issue

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

Other

@makombe
Copy link
Contributor

makombe commented Jul 12, 2024

@its-kios09 can you please ticket this in the OpenMRs jira. Thanks

@brandones
Copy link
Contributor

@its-kios09 echoing @makombe , please file a Jira ticket for record-keeping. In the ticket, please name the organization that is requesting this.

My only concern about the implementation is that this will make the up and down arrows increment the dose by 0.1, which is strange. Unfortunately this is the only way to support this with the current carbon react. There is a bug from 2020 which would allow fixing this by changing the step to step="any". Looks like an easy ticket for anyone with a dev environment set up for Carbon.

@its-kios09
Copy link
Contributor Author

its-kios09 commented Jul 16, 2024

@brandones @makombe @mogoodrich i have shared my ticket

@its-kios09 its-kios09 changed the title (fix) allowed decimal values on dose textfield (fix) allowed decimal values on dose textfield Jul 16, 2024
@its-kios09 its-kios09 changed the title (fix) allowed decimal values on dose textfield (fix) O3-3608 - Allowed decimal values on dose textfield Jul 16, 2024
@brandones
Copy link
Contributor

Thank you @its-kios09 . Please fix CI.

@its-kios09
Copy link
Contributor Author

Thank you @its-kios09 . Please fix CI.

@brandones it is working now

@denniskigen
Copy link
Member

denniskigen commented Jul 17, 2024

Strictly speaking, the NumberInput component supports decimal values out of the box. Without a defined step attribute, the default increment/decrement buttons (not enabled here because of the hideSteppers attribute) typically adjust the value by 1. However, this doesn't prevent users from manually entering decimal values.

Setting the step to 0.1 makes it so that:

  • When the input is focused, using the up and down arrow keys will increase or decrease the value by 0.1.
  • Users can still type in any value, including those that don't align with the step (e.g. 0.05).
  • The input will be considered valid for multiples of 0.1 from the min value.

I've amended the PR title to express that.

@denniskigen denniskigen changed the title (fix) O3-3608 - Allowed decimal values on dose textfield (feat) O3-3608: Adjust step precision for the dose field in the DrugOrder form Jul 17, 2024
@brandones
Copy link
Contributor

@denniskigen based on the video in the ticket, it would appear that the NumberInput does not accept decimal values when the step prop is not set.

@denniskigen
Copy link
Member

Could you try in this demo example here https://carbondesignsystem.com/components/number-input/usage/

@ibacher
Copy link
Member

ibacher commented Jul 17, 2024

It's not a validation on the level of Carbon, but one implemented by the browser for <input type="number" /> with a step attribute (see here). Unfortunately, Carbon both decides step must be a number (which is Carbon's deviation from the HTML spec) and defaults it to 1 if unset (in line with the browser spec), but does mean that by default Carbon's NumberInputs don't actually allow you to submit a form with decimal values.

@brandones brandones merged commit d93e9ee into openmrs:main Jul 17, 2024
6 checks passed
@denniskigen
Copy link
Member

Related: 7f84c03

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.

6 participants