plotly / plotly/dash

Setting dash_table.DataTable editability to False does not work after pasting multiple values

Open
#2,083 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug dash-data-table P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

ENV

dash                 2.5.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
- OS: iOS
- Browser: Chrome
- Version: 102.0.5005.61

Describe the bug

One of the dash_table.DataTable property is "editable". When this value is set to "True", user can modify the values in the table. After pasting in multiple values (i.e., from Excel table), then changing the value of "editable" from "True" to "False", table remains editable.

Expected behaviour

After setting property "editable" from "True" to "False", table should always be locked from modification, regardless whether values were edited one-by-one or a vector/matrix of values was pasted from a clipboard.

STRs

  1. Test basic behaviour:
  • Run the app from the code below
  • Press "Edit" button
  • Modify the data by editing manually some values
  • Press "Save" button
  • Test if you modify the data - it should not be possible! :)
  1. Test bugged behaviour:
  • Run the app from the code below
  • Press "Edit" button
  • Open Excel, create a single column with 3 rows, copy this vector of 3 values
  • Paste the values into the DataTable in the Dash app
  • Press "Save" button
  • Test if you can modify the data - it is still possible! :(

Minimal app to reproduce the issue

import dash
from dash.dependencies import Input, Output, State
import dash_table
import dash_core_components as dcc
import dash_html_components as html


app = dash.Dash(__name__)

params = ["Text", "Number"]

table = dash_table.DataTable(
    id="materials-table",
    columns=([{"id": p, "name": p} for p in params]),
    data=[
        {"Text": "A", "Number": 10},
        {"Text": "B", "Number": 20},
        {"Text": "C", "Number": 200},
    ],
    editable=False,
)


editable_button = [
    html.Button(
        id="editable-button",
        children="Edit",
        n_clicks=0,
    ),
]


app.layout = html.Div(
    [
        table,
        html.Div(editable_button),
    ]
)


@app.callback(
    Output("materials-table", "editable"),
    Output("editable-button", "children"),
    Input("editable-button", "n_clicks"),
    prevent_initial_call=True,
)
def toggle_editability(n_clicks):
    if n_clicks % 2 == 1:
        return True, "Save"

    else:
        return False, "Edit"


if __name__ == "__main__":
    app.run_server(debug=True)

If applicable, add screenshots or screen recording to help explain your problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Python app using dash_table.DataTable and its editable callback, then reproduce the manual-edit and multi-cell paste sequences described in the issue. Trace how changing editable from True to False is applied after a paste. Done means the table remains locked after saving in both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.