-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Component name
number type TextFields validate and format numbers as decimals. Update the component to allow the user to define whether the number should be treated as a decimal or an integer. In integer mode the user would be unable to enter a decimal point or create decimal numbers.
Required components
n/a
Examples
Metafields
Primary use case is the existing implementation of Integer and Decimal metafields, which are distinctly different metafield types. Current implementation treats these fields as string TextFields and includes custom validations, but this limits what we can do with the field compared to native Polaris support.
Inventory
Inventory and other real-world quantities are counted in whole numbers and have no need for decimal amounts. An integer input type will simplify this for users and reduce chances of input error.
Props
Propose adding an integer TextField type alongside the existing number.
ie. type (optional): integer defaults to string – Change TextField type to number and only accept integer inputs.
Subtype name
n/a
Best practices
The integer type TextField component should:
- Render and behave as a number field, as per the existing
numbertype - Disallow input of alphabetical characters or a decimal point
. - Accept only numeric integers as an input
- Be used for whole quantities, or other situations where a number or count is indivisible
- Be used for rendering Integer type metafields
Content guidelines
| Do example | Don’t example |
|---|---|
| 1 | 1.0 |
Subcomponent name
n/a