Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dash 1.11 initial callback edge case #1223

Closed
alexcjohnson opened this issue May 1, 2020 · 0 comments
Closed

[BUG] Dash 1.11 initial callback edge case #1223

alexcjohnson opened this issue May 1, 2020 · 0 comments
Assignees
Labels
bug something broken

Comments

@alexcjohnson
Copy link
Collaborator

alexcjohnson commented May 1, 2020

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):
Screen Shot 2020-05-01 at 4 52 25 PM

Reported by @Marc-Andre-Rivet in plotly/dash-core-components#792 (comment)

@alexcjohnson alexcjohnson self-assigned this May 1, 2020
@alexcjohnson alexcjohnson added the bug something broken label May 1, 2020
alexcjohnson added a commit that referenced this issue May 1, 2020
fix #1223 - initialcall on new layout chunk edge case
noisycomputation pushed a commit to noisycomputation/dash that referenced this issue May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

1 participant