spectrum-web-components
spectrum-web-components copied to clipboard
[Bug]: Clicking on a table row does not select the associate item
Code of conduct
- [X] I agree to follow this project's code of conduct.
Impacted component(s)
Table
Expected behavior
Clicking on an <sp-table-row> in an <sp-table selects="single|multiple"> should toggle the section of the item.
Actual behavior
Clicking on the row selects the item, but then it becomes unselected.
Screenshots
No response
What browsers are you seeing the problem in?
No response
How can we reproduce this issue?
No response
Sample code that illustrates the problem
No response
Logs taken while reproducing problem
No response
Will refer the documentation and try to implement it in our organizer code base.
@Westbrook , I do not get the selected item(Or, item.id) in the itemValue, neither in my application code nor in the example code that is shared, as discussed we would need the selected item: https://studio.webcomponents.dev/edit/XZEYXGb1cWTttk2S889L/src/index.ts?p=stories

The IDs of selected items (indexes by default, but this demo leverages the itemValue property that we've discussed previously) come as an array on the selected property. You can see this in the data logged to the console via console.log(e.target.selected). This is how the data you are looking for here will be surfaced as it gives you the clearest path to leveraging the Table as source of this selection data without having to rebuild management for this data in your application.
Yes, I could see the array of ids on selecting the table row. But, we need the specific current item on selecting the table row, we discussed something like sending it in event.currentTarget.item so that we have just the selected item on selecting the row which we want to pass to our OrganizerSelectionStore to keep a track of the selected elements.
The specific item selected will be of no use in the near future when we add shift + click interactions (see #2456) that could add any number of items to the selection list at the same time. Managing the selected value as an array and comparing that with what you have cached in your application is the best path towards understanding the selection at any one time.
Sure, selected values are fine. We can close this ticket.