plotly / dash-table

OBSOLETE: now part of https://github.com/plotly/dash
https://dash.plotly.com
MIT License
420 stars 74 forks source link

"Too much recursion" error when hiding a Dash Table #877

Open ndrezn opened 3 years ago

ndrezn commented 3 years ago

When using a Dash Table which can be hidden, e.g. by changing the style or nesting inside of a dbc.Collapse component, an initially hidden Dash Table with fill_width set to True will throw an indecipherable too much recursion error.

Minimal example

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

app = dash.Dash()
server = app.server

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")

app.layout = html.Div(
    [
        html.Div(
            children=[
                dash_table.DataTable(
                    id="table",
                    columns=[{"name": i, "id": i} for i in df.columns],
                    data=df.to_dict("records"),
                    fill_width=False,
                )
            ],
            id="table-container",
            style={"display": "none"},
        ),
        html.Button(children="Show table", id="toggle", n_clicks=0),
    ]
)

@app.callback(
    [Output("table-container", "style"), Output("toggle", "children")],
    [Input("toggle", "n_clicks")],
)
def hide_table(n_clicks):
    if n_clicks % 2 == 1:
        return {"display": "none"}, "Show table"
    return None, "Hide table"

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

Screen recording

Error (with table initially hidden)

https://user-images.githubusercontent.com/38958867/110658638-d774e200-818f-11eb-9fa8-2f0df34d128f.mov

Expected behavior (with table initially visible)

https://user-images.githubusercontent.com/38958867/110658214-7fd67680-818f-11eb-9714-082ff3c14ac8.mov

jonas37 commented 3 years ago

Same issue here, really yould like to see a fix

LeoWanty commented 2 years ago

I have similar issue on Dash Table but I'm not trying to hide the table.

At first glance, it looks to be linked to fixed_row options and column widths specification (I know there are some unwanted behaviors on such combination of styles). I'll come back later when I get the time to investigate deeper the source of the issue on my side.