diff --git a/CHANGELOG.md b/CHANGELOG.md index 088014c3e..574d84f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - [#722](https://github.com/plotly/dash-table/pull/722) Fix a bug where row height is misaligned when using fixed_columns and/or fixed_rows - [#728](https://github.com/plotly/dash-table/pull/728) Fix copy/paste on readonly cells - [#724](https://github.com/plotly/dash-table/pull/724) Fix `active_cell` docstring: clarify optional nature of the `row_id` nested prop +- [#731](https://github.com/plotly/dash-table/pull/731) Fix a bug where `data=None` and `columns=None` caused the table to throw an error ## [4.6.2] - 2020-04-01 ### Changed diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..b6302a609 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +testpaths = tests/ +addopts = -rsxX -vv +log_format = %(asctime)s | %(levelname)s | %(name)s:%(lineno)d | %(message)s +log_cli_level = ERROR diff --git a/src/dash-table/components/Table/props.ts b/src/dash-table/components/Table/props.ts index 9fc5771d6..67fa48335 100644 --- a/src/dash-table/components/Table/props.ts +++ b/src/dash-table/components/Table/props.ts @@ -341,12 +341,10 @@ export interface IProps { interface IDefaultProps { active_cell: ICellCoordinates; column_selectable: Selection; - columns: Columns; dropdown: StaticDropdowns; dropdown_conditional: ConditionalDropdowns; dropdown_data: DataDropdowns; css: IStylesheetRule[]; - data: Data; editable: boolean; export_columns: ExportColumns; export_format: ExportFormat; @@ -410,6 +408,8 @@ export type PropsWithDefaults = IProps & IDefaultProps; export type SanitizedProps = Omit + return R.isNil(columns) || !R.any((column: any) => column.format && ( ( column.format.symbol && diff --git a/tests/selenium/test_empty.py b/tests/selenium/test_empty.py new file mode 100644 index 000000000..6c62b9e22 --- /dev/null +++ b/tests/selenium/test_empty.py @@ -0,0 +1,46 @@ +import dash +from dash.dependencies import Input, Output +from dash.exceptions import PreventUpdate + +from dash_table import DataTable +from dash_html_components import Button, Div + + +def get_app(): + app = dash.Dash(__name__) + + columns = [{"name": i, "id": i} for i in ["a", "b"]] + data = [dict(a=1, b=2), dict(a=11, b=22)] + + app.layout = Div( + [ + Button(id="clear-table", children=["Clear table"]), + DataTable(id="table", columns=columns, data=data), + ] + ) + + @app.callback( + [Output("table", "data"), Output("table", "columns")], + [Input("clear-table", "n_clicks")], + ) + def clear_table(n_clicks): + if n_clicks is None: + raise PreventUpdate + + nonlocal columns, data + + return (data, columns) if n_clicks % 2 == 0 else (None, None) + + return app + + +def test_empt001_clear_(test): + test.start_server(get_app()) + + target = test.table("table") + + assert target.is_ready() + assert len(test.driver.find_elements_by_css_selector("tr")) == 3 + test.driver.find_element_by_css_selector("#clear-table").click() + assert target.is_ready() + assert len(test.driver.find_elements_by_css_selector("tr")) == 0