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

Number Input support for numbers with a dot and no decimals #1668

Open
GomezIvann opened this issue Aug 2, 2023 · 2 comments
Open

Number Input support for numbers with a dot and no decimals #1668

GomezIvann opened this issue Aug 2, 2023 · 2 comments
Labels
enhancement New feature or request jira This task is referenced in a story of Jira non-closable This task is exempt from becoming stale or automatically closed.

Comments

@GomezIvann
Copy link
Collaborator

As @fredofm explains in the issue #1660, when you type:

"1," -> the component transforms this value into "1". It can make sense because as you didn't type the fractional part it will return the integer one.
"1." -> the component transforms this value into "". It can make sense but I would expect the same behaviour as "1,".

As I explained in the comments of that issue, it looks like it is a bug from the HTML <input type=" number" />, which understands the comma as a decimal number when there are no decimals at all (1,, 12,, 4483,, ...) but doesn't apply the same logic on the dotted ones.

So, the feature here is to make the component behave consistently for both scenarios since they are variants of the same use case.

@GomezIvann GomezIvann added the enhancement New feature or request label Aug 2, 2023
@GomezIvann GomezIvann changed the title Number Input support for numbers with dot and no decimals Number Input support for numbers with a dot and no decimals Aug 2, 2023
@GomezIvann GomezIvann added the jira This task is referenced in a story of Jira label Aug 3, 2023
@Mil4n0r
Copy link
Collaborator

Mil4n0r commented Jan 18, 2024

I have done some research about how the HTML5 input with type="number" works and it is quite limited in all the modern browsers due to the fact that it adapts to the browser locale.
The issue that you explain can be "turned around" if you try to use the component from, for example, an "en-US" browser.

However, it is complicated to be handled to handle all the cases, I have 2 proposals:

  1. Handle numbers as an input with type="text" and handle all the possible scenarios in code.
  2. Add a prop "separator" (with a default value) to the NumberInputContextProps in order for the wrapped DxcTextInput component to handle the logic based on it.

If you have any other suggestion, feel free to share!

@github-actions github-actions bot added the stale This task has no activity and will be closed within 15 days. label Feb 8, 2024
@Mil4n0r Mil4n0r removed the stale This task has no activity and will be closed within 15 days. label Feb 12, 2024
Copy link

This issue is stale because it has been open for 15 days with no activity. If there are no further updates or modifications within the next 15 days, it will be automatically closed.

@github-actions github-actions bot added the stale This task has no activity and will be closed within 15 days. label Feb 28, 2024
@Mil4n0r Mil4n0r added non-closable This task is exempt from becoming stale or automatically closed. and removed stale This task has no activity and will be closed within 15 days. labels Feb 28, 2024
@dxc-technology dxc-technology deleted a comment from github-actions bot Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jira This task is referenced in a story of Jira non-closable This task is exempt from becoming stale or automatically closed.
Projects
None yet
Development

No branches or pull requests

2 participants