"Clear Cell Selection" Component Method

In the (new) Table component when the cell selection option is enabled it is possible to have a selected Cell. However, I couldn't find an method to clear the cell selection. There's a method to clear the regular (row) selection, but nothing for cells.

Hi @cstork, the "Deselect row" event is generally used when multiple row selection is enabled, to do something when one of the selected rows is unselected.

For example, if we have the following rows selected:


We could show a notification when a row is unselected:

But if we have single row selection enabled, this would run every time we click a new row, which is basically the same as the "Select row" event:


Since there is no multiple cell selection (can't think of a use case for this), there is no "Deselect cell" event. Cells stay selected when they are clicked the same way rows do with single row selection.

Could your share more details about your use case?

Hi @Paulo, I'm so sorry, I didn't mean "Clear Cell Selection Event" but "Clear Cell Selection Component Method". (I edited my post accordingly.) Sorry, complete brain fart.

In my use case a click on a cell selects it and opens a modal. The selection gives visual context to the modal and once the modal is closed the cell should also be deselected.

Thank you for clarifying! We can achieve this functionality by adding an event handler to the Modal component set to "Clear selection" .

If selecting a cell opens a modal:


We can add the following event handler to clear the table selection (this works for both row and cell selection):


The cell should be unselected when closing the modal:


Let us know if you have any questions! :slightly_smiling_face:
‚Äč

Oh, of course, you're right "Clear selection" does also clear the cell selection.

However, I actually use multi-row selection in the same table and de-selecting the rows just because I want to de-select a cell does not really make sense in my use case.

Anyway, I'd just suggest that it would makes sense to provide methods for deselecting rows and cells separately.

I see, that makes perfect sense. I created a the FR and included your use case. Thank you for sharing it! :slightly_smiling_face:
We'll keep you posted with any news from our devs.