DashTable active_cell - Different Behaviour for mouse and keyboard actions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Python 3.9.7
dash 2.0.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
Describe the bug
After editing a cell in a dash_table.DataTable, the value for the tables attribute active_cell, dictionary-key row differs when pressing the Enter/Return key on a keyboard vs. when mouse-clicking anywhere outside the selected cell (even when clickin in another cell). This is true for either callback input Input("table", "data"), Input("table", "data_timestamp") or Input("table", "active_cell").
It seems active_cell is evaluated again when triggering the callback via a keyboard key press, while it is not re-evaluated when mouse-clicking in another cell.
Expected behavior
active_cell behaves identical for mouse-clicks and keyboard enter/return key presses. When a cell is selected and the return key is pressed, active_cell is not evaluated again.
Screen Capture

MWE
from dash import Dash, dash_table, html
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
app = Dash(__name__)
app.layout = html.Div([
dash_table.DataTable(
columns=[
{'name': 'Input Data', 'id': 'input-data', 'editable': True},
{'name': 'Input Squared', 'id': 'output-data'}
],
data=[{'input-data': i} for i in range(1, 3)],
id="table",
),
])
@app.callback(
Output("table", 'data'),
Input("table", "data"),
State("table", "active_cell"),
prevent_initial_call=True,
)
def update_row_value(data: dict, active_cell: dict) -> dict:
print("active_cell = ", active_cell)
data[active_cell["row"]]["output-data"] = int(data[active_cell["row"]]["input-data"]) ** 2
return data
if __name__ == '__main__':
app.run_server(debug=True)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python MWE with the listed Dash versions and compare active_cell in callbacks triggered by Enter/Return versus mouse clicks. Done means the DataTable reports the same active_cell row for both interactions, with regression coverage added in the component's existing test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100