-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] - DropdownMenu component onSelectionChange type not correct. #2512
Comments
Same applies for |
It happens |
@AlbertoEE @simPod maybe this pr can resolve your problem ? #2567 |
@winchesHe I think that the PR does not fix the problem as it looks like that type is not the intended one that should be used instead only Maybe I'm wrong but that is my gut feeling. |
@AlbertoEE You can console.log the keys value, It was |
Same problem here |
Similar issue maybe: const [value, setValue] = useState<Selection>(new Set([]));
|
Change like following const [value, setValue] = useState<Set<React.Key>>(new Set([])); |
const [openedWorkspaces, setOpenedWorkspaces] = useState<Set<Key>>(new Set([])); <Accordion
selectedKeys={openedWorkspaces}
onSelectionChange={setOpenedWorkspaces}
> hi, I still get the following error
|
I solved the issue declaring the useState like: const [selectedKeys, setSelectedKeys] = useState( new Set( [] ) ); and in the prop of onSelectionChange={(keys) => setSelectedKeys(keys as Set<string>)} Hope you find this useful! |
NextUI Version
2.2.9
Describe the bug
Context
The
<DropdownMenu />
component coming from the nextui-org/dropdown package has these 2 props:onSelectionChange
selectedKeys
If you take a look at the typescript signature of the props you will see that:
The problem
In reality if you make use of these two props and debug the insides of the parameter that is passed to the
onSelectionChange
callback, you will see that the object has this structure.Taking a look at the constructor in the debugger we can see that the type that is being returned in reality is:
After investigating a little bit I found that this type is coming from the package ``@react-stately/selection/src/Selection.ts`:
Maybe...
Could it be that the DropDown component is using this Selection from @react-stately type instead of the one shown in the signature (
export type Selection = 'all' | Set<Key>
)?I tried to look at the repo code but I'm new to Frontend in general and it was really hard to read for me so I couldn't find where to fix it so I could create a PR.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Just use a DropdownMenu like this one and debug the value that is being passed to the onSelectionChange callback.
Expected behavior
I would expect to get the type
export type Selection = 'all' | Set<Key>;
not the type coming from@react-stately/selection/src/Selection.ts
Screenshots or Videos
No response
Operating System Version
Windows 10 pro
Browser
Chrome
The text was updated successfully, but these errors were encountered: