-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bugsomething brokensomething broken
Description
There's another specific case when Dash 1.11 won't fire an initial callback:
- The output element was added to the layout after the initial render
- There's an input element higher up in the layout than the (first) output
- Another callback earlier in the chain called
PreventUpdate
Minimal reproduction:
import dash
import dash_html_components as html
from dash.dependencies import Output, Input
from dash.exceptions import PreventUpdate
app = dash.Dash(__name__, suppress_callback_exceptions=True)
layout = html.Div([
html.Div(42, id="above-in"),
html.Div(id="above-dummy"),
html.Hr(),
html.Div(0, id='above-out'),
html.Div(0, id='below-out'),
html.Hr(),
html.Div(id="below-dummy"),
html.Div(44, id="below-in"),
])
app.layout = html.Div(id="content")
@app.callback(Output("content", "children"), [Input("content", "style")])
def content(_):
return layout
# Create 4 callbacks - 2 for above, 2 for below.
for pos in ('above', 'below'):
@app.callback(
Output("{}-dummy".format(pos), "children"),
[Input("{}-dummy".format(pos), "style")]
)
def dummy(_):
raise PreventUpdate
@app.callback(
Output('{}-out'.format(pos), 'children'),
[Input('{}-in'.format(pos), 'children')]
)
def on_data(data):
return data
if __name__ == '__main__':
app.run_server(debug=True)
Actually both callbacks fire, but the above-out
callback return value is ignored (the "0" in the middle) while the below-out
callback return is used correctly (the "44" in the middle):
Reported by @Marc-Andre-Rivet in plotly/dash-core-components#792 (comment)
Metadata
Metadata
Assignees
Labels
bugsomething brokensomething broken