Skip to content

Commit c3dd40a

Browse files
committed
fix prevent_initial_call as positional arg to callback
1 parent fed4a91 commit c3dd40a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

dash/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def handle_callback_args(args, kwargs):
156156
"""Split args into outputs, inputs and states"""
157157
prevent_initial_call = kwargs.get("prevent_initial_call", None)
158158
if prevent_initial_call is None and args and isinstance(args[-1], bool):
159-
prevent_initial_call = args.pop()
159+
args, prevent_initial_call = args[:-1], args[-1]
160160

161161
# flatten args, to support the older syntax where outputs, inputs, and states
162162
# each needed to be in their own list

tests/integration/callbacks/test_prevent_initial.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,25 @@ def test_cbpi003_multi_outputs(flavor, dash_duo):
333333
dash_duo.wait_for_text_to_equal("#c", "BlueCheese")
334334
dash_duo.wait_for_text_to_equal("#b", "Cheese")
335335
dash_duo.wait_for_text_to_equal("#a", "Blue")
336+
337+
338+
def test_cbpi004_positional_arg(dash_duo):
339+
app = dash.Dash(__name__)
340+
app.layout = html.Div([html.Button("click", id="btn"), html.Div(id="out")])
341+
342+
@app.callback(
343+
Output("out", "children"),
344+
Input("btn", "n_clicks"),
345+
True
346+
)
347+
def f(n):
348+
return n
349+
350+
dash_duo.start_server(app)
351+
dash_duo._wait_for_callbacks()
352+
353+
dash_duo.wait_for_text_to_equal("#out", "")
354+
355+
dash_duo.find_element("#btn").click()
356+
357+
dash_duo.wait_for_text_to_equal("#out", "1")

0 commit comments

Comments
 (0)