Skip to content
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

Menu onSelectionChange type definition causing errors #2330

Open
3 of 6 tasks
trumpet2012 opened this issue Jul 18, 2024 · 1 comment
Open
3 of 6 tasks

Menu onSelectionChange type definition causing errors #2330

trumpet2012 opened this issue Jul 18, 2024 · 1 comment
Labels
bug Something isn't working gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle

Comments

@trumpet2012
Copy link

Description

Menu onSelectionChange not resolving to correct type.

CodeSandbox/Snack link

https://snack.expo.dev/@trumpet2012/gluestack-menu-typescript-issue

Steps to reproduce

See provided snack link for reproducible issue (note that the types aren't working in the snack for some reason but that code is enough to see the issue locally)

This is a copy of the example from the docs: https://v1.gluestack.io/ui/docs/components/overlay/menu#selection.

The typescript error is:

Property 'currentKey' does not exist on type 'Selection'.
     Property 'currentKey' does not exist on type '"all"'.

Adding an extra check to ensure that "keys" isn't "all" then leads to the following typescript error:

Property 'currentKey' does not exist on type 'Set<Key>'.

gluestack-ui Version

1.1.42

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

The type for the "keys" argument appears to be resolving to: https://github.com/adobe/react-spectrum/blob/8ee84717884461e0646236b77c9e43c5d14e3533/packages/%40react-types/shared/src/selection.d.ts#L28

However the actual keys object type looks like it should be using: https://github.com/adobe/react-spectrum/blob/8ee84717884461e0646236b77c9e43c5d14e3533/packages/%40react-stately/selection/src/Selection.ts#L19.

@trumpet2012 trumpet2012 added the bug Something isn't working label Jul 18, 2024
@trumpet2012
Copy link
Author

trumpet2012 commented Jul 18, 2024

Looking into this more it looks like gluestack is using the older "react-stately" package: https://github.com/adobe/react-spectrum/blob/react-stately%403.21.0/packages/react-stately/src/index.ts for defining the type instead of the newer "@react-stately" package.

Edit: not sure if this is a case of older vs newer package. I'm unfamiliar with that code base. I am however starting to think that this might be an issue with the types provided by react-spectrum.

@Viraj-10 Viraj-10 added the gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle
Projects
Status: Backlog
Development

No branches or pull requests

2 participants