adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.12k stars 1.06k forks source link

Hope that Radio and Checkbox will support the Number type #6628

Open GuoXiaoyang opened 4 days ago

GuoXiaoyang commented 4 days ago

Provide a general summary of the feature here

I hope that Radio and Checkbox will support the Number type, as they currently only support strings.

๐Ÿค” Expected Behavior?

The value of RadioGroupProps/RadioProps/CheckboxGroupProps/Checkbox can also support number or number[].

๐Ÿ˜ฏ Current Behavior

The value of RadioGroupProps/RadioProps/CheckboxGroupProps/Checkbox only support string or string[]. And actually the input tag supports number value. Why not support number?

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

In our development, some data gotten from the server is only number list. These data is hard to be used in RadioGroup or CheckboxGroup component as they had to be transformed to string.

๐Ÿ’ป Examples

No response

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

snowystinger commented 4 days ago

Looks like we just need to update the types https://github.com/adobe/react-spectrum/blob/6288d4a3a886a52473d763dde569e0f7fb33d11e/packages/%40react-types/radio/src/index.d.ts#L45

We already support it in the logic it appears https://codesandbox.io/p/sandbox/goofy-lake-l2czh8?file=%2Fsrc%2FApp.js%3A13%2C20

uniqueeest commented 4 days ago

Hi @LFDanLu I want to resolve this issue.

LFDanLu commented 3 days ago

@uniqueeest go for it! As @snowystinger linked above, it seems like that type needs to be updated to be string | number. Also please take a look at https://react-spectrum.adobe.com/contribute.html for steps you'll need to do before contributing.