Skip to content

Commit eb76e8e

Browse files
alexcjohnsonnoisycomputation
authored andcommitted
fix plotly#1223 - initialcall on new layout chunk edge case
1 parent 599cccb commit eb76e8e

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

dash-renderer/src/actions/dependencies.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1209,10 +1209,14 @@ export function getCallbacksInLayout(graphs, paths, layoutChunk, opts) {
12091209
if (callback) {
12101210
const foundIndex = foundCbIds[callback.resolvedId];
12111211
if (foundIndex !== undefined) {
1212-
callbacks[foundIndex].changedPropIds = mergeMax(
1213-
callbacks[foundIndex].changedPropIds,
1212+
const foundCb = callbacks[foundIndex];
1213+
foundCb.changedPropIds = mergeMax(
1214+
foundCb.changedPropIds,
12141215
callback.changedPropIds
12151216
);
1217+
if (callback.initialCall) {
1218+
foundCb.initialCall = true;
1219+
}
12161220
} else {
12171221
foundCbIds[callback.resolvedId] = callbacks.length;
12181222
callbacks.push(callback);

tests/integration/callbacks/test_multiple_callbacks.py

+40
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,43 @@ def on_click(n_clicks):
262262
dash_duo.wait_for_text_to_equal("#output", "1")
263263
dash_duo.find_element("#btn").click()
264264
dash_duo.wait_for_text_to_equal("#output", "2")
265+
266+
267+
def test_cbmt007_early_preventupdate_inputs_above_below(dash_duo):
268+
app = dash.Dash(__name__, suppress_callback_exceptions=True)
269+
app.layout = html.Div(id="content")
270+
271+
@app.callback(Output("content", "children"), [Input("content", "style")])
272+
def content(_):
273+
return html.Div([
274+
html.Div(42, id="above-in"),
275+
html.Div(id="above-dummy"),
276+
html.Hr(),
277+
html.Div(0, id='above-out'),
278+
html.Div(0, id='below-out'),
279+
html.Hr(),
280+
html.Div(id="below-dummy"),
281+
html.Div(44, id="below-in"),
282+
])
283+
284+
# Create 4 callbacks - 2 above, 2 below.
285+
for pos in ('above', 'below'):
286+
@app.callback(
287+
Output("{}-dummy".format(pos), "children"),
288+
[Input("{}-dummy".format(pos), "style")]
289+
)
290+
def dummy(_):
291+
raise PreventUpdate
292+
293+
@app.callback(
294+
Output('{}-out'.format(pos), 'children'),
295+
[Input('{}-in'.format(pos), 'children')]
296+
)
297+
def out(v):
298+
return v
299+
300+
dash_duo.start_server(app)
301+
302+
# as of https://github.com/plotly/dash/issues/1223, above-out would be 0
303+
dash_duo.wait_for_text_to_equal("#above-out", "42")
304+
dash_duo.wait_for_text_to_equal("#below-out", "44")

0 commit comments

Comments
 (0)