# Pattern-matched Input does not trigger callback

**URL:** <https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449>\
**Category:** Dash Python\
**Created:** [April 28, 2021, 4:50pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449 "2021-04-28T16:50:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DPly](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@DPly](https://community.plotly.com/u/DPly)\
**Post date:** [April 28, 2021, 4:50pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/1 "2021-04-28T16:50:44Z")

</div>

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](https://dash.plotly.com/pattern-matching-callbacks#todo-app).

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):

```auto
@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):

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Elliott](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Elliott](https://community.plotly.com/u/Elliott)\
**Post date:** [December 5, 2022, 4:36pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/2 "2022-12-05T16:36:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 5, 2022, 4:48pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/3 "2022-12-05T16:48:45Z")

</div>

Hello @Elliott,

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

---

<div class="post-metadata">

**Author:** ![Elliott](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Elliott](https://community.plotly.com/u/Elliott)\
**Post date:** [December 7, 2022, 9:07am UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/4 "2022-12-07T09:07:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Elliott](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Elliott](https://community.plotly.com/u/Elliott)\
**Post date:** [December 7, 2022, 10:29am UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/5 "2022-12-07T10:29:17Z")

</div>

@jinnyzor thanks again for the reply. I ended up getting past the problem using the solution [here](https://github.com/plotly/dash/issues/1300).

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 7, 2022, 11:31am UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/6 "2022-12-07T11:31:52Z")

</div>

Ooo. Ok. Nice.

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

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 7, 2022, 1:12pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/7 "2022-12-07T13:12:24Z")

</div>

@Elliott,

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

---

<div class="post-metadata">

**Author:** ![Elliott](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@Elliott](https://community.plotly.com/u/Elliott)\
**Post date:** [December 7, 2022, 1:56pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/8 "2022-12-07T13:56:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 7, 2022, 2:26pm UTC](https://community.plotly.com/t/pattern-matched-input-does-not-trigger-callback/52449/9 "2022-12-07T14:26:30Z")

</div>

Hmm. Ok.

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