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

<uui-input> number onInput value sync #1004

Open
leekelleher opened this issue Feb 4, 2025 · 1 comment
Open

<uui-input> number onInput value sync #1004

leekelleher opened this issue Feb 4, 2025 · 1 comment
Labels
bug Something isn't working needs triage This issue has not been tested by a team member yet

Comments

@leekelleher
Copy link
Member

Which exact UI Library version are you using? For example: 1.0.1 - don't just write v1.

1.12.2

Bug summary

When using <uui-input type="number"> with a decimal value, deleting the decimal places causes the input to auto remove the dot and refocus the text-cursor to the start of the input.

Specifics

The onInput event of the <uui-input> component attempts to keep the value in sync with the inner <input> element.

ref: https://github.com/umbraco/Umbraco.UI/blob/v1.12.2/packages/uui-input/lib/uui-input.element.ts#L269

When using the number input type, this can cause a jarring effect as the numeric value rendered on-screen is not the same as the <input type=number>'s inner value.

For example, if you type 123.456, then delete the last 456, (making the value 123., with dot), the inner value (from HTMLInputElement) would be 123 (without dot). This will cause the <uui-input> to update the value and set the focus/cursor at the start of the input.

Recording.2025-02-04.153134.mp4

Steps to reproduce

  1. Configure an <uui-input type="number"> component, (or visit the Number Input Storybook page).
  2. Input the value 123.456.
  3. Delete the characters 456, (leaving the value as 123., don't delete the dot).
  4. Notice that the value has changed to 123 and the focus/text-cursor is at the start of the input.

Expected result / actual result

That the <uui-input type="number"> component acts the same as <input type="number">, so that the text value of the input is what has been entered and not evaluated from the DOM.

@leekelleher
Copy link
Member Author

To add a discussion point on this issue, what do we think about allowing the step attribute to accept a value of "any"? 🤔
re: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage This issue has not been tested by a team member yet
Projects
None yet
Development

No branches or pull requests

1 participant