adobe / adobe/react-spectrum

NumberField isn't always clear when it converts a number

Open
#1,879 0 comments 0 reactions 0 assignees View on GitHub
NumberField
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

# 📝 Feedback

A German user pasting the value "22.2222" (an English formatted number possibly) into the input will cause the component to try to parse it as "222.222". The NumberField should be clearer that it has done this as it's a very small change and hard to necessarily see.

Some suggestions have been:
Leave it as is. This has the downside of not being transparent that we have parsed a different way potentially since we don't emit the string onChange, we only emit a number.
Mark as invalid. Maybe not the most intuitive. Do we leave the input as is in this situation and not try to parse? Or is there some way to indicate, your value will/has change(d).

There's the added consideration of a NumberField with a max of 100 in the previous example, currently the NumberField will clamp to that max if the number entered is larger, so "22.2222" pasted into a German users page would turn into "100" on blur, which is also confusing.

## 🔦 Context

originally reported here: https://twitter.com/PipoPeperoni/status/1390379294212378625

## 💻 Code Sample

## 🌍 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| [Package name] |
| Browser |
| Operating System |

## 🧢 Your Company/Team

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.