plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.19k stars 2.04k forks source link

allow deselect active_cell in datatable #1864

Open sebihoefle opened 2 years ago

sebihoefle commented 2 years ago

Is your proposal related to a problem?

The dash datatable supports to select and highlight a cell. However, deselecting an active cell is not possible, as clicking on an already active cell is ignored: https://github.com/plotly/dash/blob/6cfb7874800152794d8d603e8d9c4334bf61e3fd/components/dash-table/src/dash-table/handlers/cellEvents.ts#L31-L34

Describe the solution you'd like

In my use case, I need to update other components based on the selected cells in the table. Having none of the cells selected is a valid option, as it is the natural situation before having selected any cell on startup. Therefore, I would like to receive an event when an active cell is "deselected". I understand, that not all the use cases would like to have this behaviour. Therefore, one could introduce a new property like cell_deselectable which would propagate that event.

Describe alternatives you've considered

Instead of just selecting a cell, in my use case, where I am interested in row selection, I could workaround using the row_selectable flag. However, the extra column for the checkbox is wasting space and does not feel good, if one could just click any cell of the row to select the row.

Other workarounds were provided here, but add a lot of extra code for this simple feature: https://community.plotly.com/t/unselect-active-cell-datatable/43124

sebihoefle commented 2 years ago

Example use case and implementation in the PR mentioned above.

luiztauffer commented 1 year ago

this is really needed in some cases, it'd be great if their dev team consider looking at it and merge your PR