adobe/react-spectrum

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

Open

#2806 aperta il 4 feb 2022

Vedi su GitHub
 (10 commenti) (0 reazioni) (0 assegnatari)TypeScript (1500 fork)auto 404
bughelp wanted

Metriche repository

Star
 (15.634 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

🐛 Bug Report

I am using the useNumberField with the "formatOptions" option to add units to the number fields.

Using the following option works fine:

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).

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

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

Guida contributor