Pattern-matched Input does not trigger callback

I am having a problem with pattern-matched inputs not triggering a callback in my app.

To investigate, I created a test.py file in the same folder and used the exact code from the ToDo app on the Pattern-Matching-Callbacks man page, here.

I modified the edit_list def to output some print statements as soon as it is called, and that worked fine.

I then swapped this Input line:

Input("add", "n_clicks"),

to this:

Input({"type": "add", "index": ALL}, "n_clicks"),

and immediately saw the same problem that I am experiencing - the callback was not called. Clicking the add button now does nothing. Here is the full modified callback (the rest of the code is identical to the original To-Do example):

@app.callback(
    [
        Output("list-container", "children"),
        Output("new-item", "value")
    ],
    [
        Input({"type": "add", "index": ALL}, "n_clicks"),
        Input("new-item", "n_submit"),
        Input("clear-done", "n_clicks")
    ],
    [
        State("new-item", "value"),
        State({"index": ALL}, "children"),
        State({"index": ALL, "type": "done"}, "value")
    ]
)
def edit_list(add, add2, clear, new_item, items, items_done):
    triggered = [t["prop_id"] for t in dash.callback_context.triggered]
    print(dash.callback_context.triggered)
    print('triggered: ', triggered)
    print('items_done: ', items_done)
    print('items: ', items)
    adding = len([1 for i in triggered if i in ("add.n_clicks", "new-item.n_submit")])
    ... etc (no further changes) ...

My requirements.txt file (note that the imports in test.py remain the same as in the original ToDo app):

dash==1.20.0
dash_core_components
dash_html_components
dash_bootstrap_components
dash-extensions==0.0.53
plotly==4.14.1
pandas==1.1.5
numpy===1.19.3
ipywidgets==7.5.1
statsmodels==0.12.1
scikit-learn==0.23.2
matplotlib==3.3.3
scipy==1.5.4
mariadb==1.0.5
gunicorn==20.0.4

I’m running into this same issue. Has anybody found a fix yet?

Hello @Elliott,

Could you please provide your code so that we can try to emulate on our machines?

Hi @jinnyzor, sorry I assumed that the above example would suffice. Let me work on setting up a MWE.

@jinnyzor thanks again for the reply. I ended up getting past the problem using the solution here.

Ooo. Ok. Nice.

Yeah. Click data because technically it’s not changing wouldn’t trigger a change prop.

@Elliott,

For this, is there a timestamp for the clickData that you could use to trigger it?

Unfortunately no. I was thinking the n_clicks would have been useful, as I have used it before to get an element to refresh, but for some reason, the callback doesn’t fire when using n_clicks in a pattern-matched input in this particular case.

Hmm. Ok.

I think I will encounter this issue today with something I am working on.