spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

[Bug]: Clicking on a table row does not select the associate item

Open Westbrook opened this issue 3 years ago • 4 comments

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

Westbrook avatar Aug 04 '22 16:08 Westbrook

Will refer the documentation and try to implement it in our organizer code base.

harprees avatar Aug 07 '22 15:08 harprees

@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 Screenshot 2022-08-09 at 3 32 29 PM

harprees avatar Aug 09 '22 10:08 harprees

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.

Westbrook avatar Aug 09 '22 11:08 Westbrook

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.

harprees avatar Aug 09 '22 17:08 harprees

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.

Westbrook avatar Aug 11 '22 22:08 Westbrook

Sure, selected values are fine. We can close this ticket.

harprees avatar Aug 13 '22 16:08 harprees