-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] - Select not working correctly with numbers #2926
Comments
Thanks for the issue! This issue stems from React converting the key to a string.
See: https://react-spectrum.adobe.com/react-stately/collections.html#unique-keys While it can be resolved by assigning an id to items as shown below, but the current situation requires a key, so some adjustments need to be made. I'm currently working on this fix. let [years, setYears] = useState([
{id: 1, value: 2024},
{id: 2, value: 2025},
{id: 3, value: 2026}
]);
<Select items={years}>
{item => <SelectItem>{item.value}</SelectItem>}
</Select> |
NextUI Version
2.3.6
Describe the bug
Select component seems to accept numbers, and given this type definitions
it indeed seems possible. However, when you provide numbers as items of Select, in
onSelectionChange
,keys
is alwaysSet<string>
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
when selecting a item, log statement prints
{'2024'}
(but should{2024}
)Expected behavior
value
inonSelectionChange
should beSet<number>
Screenshots or Videos
No response
Operating System Version
macOS
Browser
Chrome
The text was updated successfully, but these errors were encountered: