|
3 | 3 |
|
4 | 4 | import dash_html_components as html
|
5 | 5 | import dash_core_components as dcc
|
| 6 | +import dash_table |
6 | 7 | import dash
|
7 | 8 | from dash.dependencies import Input, Output
|
8 | 9 | from dash.exceptions import PreventUpdate
|
@@ -72,3 +73,54 @@ def set_c(a):
|
72 | 73 | dash_duo.find_element("#a").send_keys(str(i))
|
73 | 74 | chars += str(i)
|
74 | 75 | dash_duo.wait_for_text_to_equal("#out", "{0}/b/{0}".format(chars))
|
| 76 | + |
| 77 | + |
| 78 | +def test_cbmt003_chain_with_table(dash_duo): |
| 79 | + # see https://github.com/plotly/dash/issues/1071 |
| 80 | + app = dash.Dash(__name__) |
| 81 | + app.layout = html.Div([ |
| 82 | + html.Div(id="a1"), |
| 83 | + html.Div(id="a2"), |
| 84 | + html.Div(id="b1"), |
| 85 | + html.H1(id="b2"), |
| 86 | + html.Button("Update", id="button"), |
| 87 | + dash_table.DataTable(id="table"), |
| 88 | + ]) |
| 89 | + |
| 90 | + @app.callback( |
| 91 | + # Changing the order of outputs here fixes the issue |
| 92 | + [Output("a2", "children"), Output("a1", "children")], |
| 93 | + [Input("button", "n_clicks")], |
| 94 | + ) |
| 95 | + def a12(n): |
| 96 | + return "a2: {!s}".format(n), "a1: {!s}".format(n) |
| 97 | + |
| 98 | + @app.callback(Output("b1", "children"), [Input("a1", "children")]) |
| 99 | + def b1(a1): |
| 100 | + return "b1: {!r}".format(a1) |
| 101 | + |
| 102 | + @app.callback( |
| 103 | + Output("b2", "children"), |
| 104 | + [Input("a2", "children"), Input("table", "selected_cells")], |
| 105 | + ) |
| 106 | + def b2(a2, selected_cells): |
| 107 | + return "b2: {!r}, {!r}".format(a2, selected_cells) |
| 108 | + |
| 109 | + dash_duo.start_server(app) |
| 110 | + |
| 111 | + dash_duo.wait_for_text_to_equal("#a1", "a1: None") |
| 112 | + dash_duo.wait_for_text_to_equal("#a2", "a2: None") |
| 113 | + dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: None'") |
| 114 | + dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: None', None") |
| 115 | + |
| 116 | + dash_duo.find_element("#button").click() |
| 117 | + dash_duo.wait_for_text_to_equal("#a1", "a1: 1") |
| 118 | + dash_duo.wait_for_text_to_equal("#a2", "a2: 1") |
| 119 | + dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 1'") |
| 120 | + dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 1', None") |
| 121 | + |
| 122 | + dash_duo.find_element("#button").click() |
| 123 | + dash_duo.wait_for_text_to_equal("#a1", "a1: 2") |
| 124 | + dash_duo.wait_for_text_to_equal("#a2", "a2: 2") |
| 125 | + dash_duo.wait_for_text_to_equal("#b1", "b1: 'a1: 2'") |
| 126 | + dash_duo.wait_for_text_to_equal("#b2", "b2: 'a2: 2', None") |
0 commit comments