adobe / adobe/react-spectrum

Unit in NumberField cannot be deleted (for some units/ unit-displays)

Open
#2,806 10 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

# 🐛 Bug Report
I am using the useNumberField with the "formatOptions" option to add units to the number fields.

Using the following option works fine:
```typescript
formatOptions={{
style: "unit",
unit: "gram",
}}
```

But when I am using the "milliliter" unit, the unit's letters cannot be deleted (by pressing the backspace or the delete key).
```typescript
formatOptions={{
style: "unit",
unit: "milligram",
}}
```

When using `unitDisplay="long` only the last letter can be deleted.

## 🤔 Expected Behavior

Pressing the backspace or the delete key should delete unit's letters inside the input.

## 😯 Current Behavior
Pressing the backspace or the delete key does not always delete the unit's letters inside the input.

## 💁 Possible Solution

## 🔦 Context

## 💻 Code Sample

[Codesandbox reproduction](https://codesandbox.io/s/react-spectrum-number-field-unit-issues-e8i4y?file=/src/App.js)

Go to the codesandbox and focus one NumberField after another to see which letters of which units can be deleted and which cannot.

## 🌍 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| react-spectrum |3.9.0
| Browser |
| Operating System |

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.