Open ArrayKnight opened 5 months ago
Looks like we left out the onAction documentation for ListBox https://react-spectrum.adobe.com/react-aria/GridList.html#row-actions
What you want though is https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior to set this to "Replace" Then the default interaction will be selection and a double click will trigger the action, as it mentions in the GridList docs I linked to.
Otherwise, you need to provide a control to trigger selection on individual rows.
Hi! I'm facing a similar issue. I raised this as an issue and was recommended to use onAction. However, Iโve noticed that the onSelectionChange callback only fires when I hold down the option, which is not the behavior Iโm expecting. Has anyone else encountered this problem? Iโd appreciate any suggestions or alternative solutions.
@elianarlivingston was my previous comment able to explain it?
This issue is just open to add docs now
Hello, @snowystinger
Thank you for the previous clarification. I still have a couple of questions regarding the implementation of the useListBox hook, specifically about the behavior of the onAction and onSelectionChange functions.
I've noticed that when selecting an item, both functions execute correctly: onAction is invoked when an element is selected, and onSelectionChange updates the selection state. However, when deselecting an item, onAction does not execute, while onSelectionChange does get triggered to reflect the change in selection.
Is this behavior expected? I would like to understand why onAction does not get activated during deselection and if there is a recommended way to handle the logic associated with deselection in this context.
I appreciate your help and guidance.
Best regards
Can you provide a codesandbox demonstrating the issue? It will make figuring out what's going on much easier.
Provide a general summary of the issue here
Not sure if this is intended and undocumented or a bug
If you add an event listener to the
onAction
prop on theListBox
component, the standard selection behavior ceases to functionMaybe the expectation is that if you're listening to
onAction
you're handling all selection state externally(?)I discovered this when implementing a story for the component and binding all event handler props to actions (logs)
๐ค Expected Behavior?
Either document this as expected behavior or allow for
onAction
to be listened to without breaking internal selection state management๐ฏ Current Behavior
Binding
onAction
causes presses to not update selection state๐ Possible Solution
No response
๐ฆ Context
No response
๐ฅ๏ธ Steps to Reproduce
https://codesandbox.io/p/sandbox/amazing-solomon-ypvhz7
Version
1.2.1
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Mac
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response