Is anyone aware of an issue with using Input({"type": "control", "id": ALL}, "value") as a callback input?

I’m trying to implement unique URLs for each combination of control input values on my page. I’m following the example provided here:
Multi-Page Apps and URL Support | Dash for Python Documentation | Plotly

Here is my callback:

@callback(
    Output("main-url", "hash", allow_duplicate=True),
    Input({"type": "control", "id": ALL}, "value"),
    prevent_initial_call=True,
)
def update_hash(_values):
    """Update the hash in the URL Location component to represent the app state.

    The app state is json serialised then base64 encoded and is treated with the
    reverse process in the layout function.
    """
    app.logger.info("update_hash callback fired")
    return "#" + base64.b64encode(
        json.dumps({inp["id"]["id"]: inp["value"] for inp in ctx.inputs_list[0]})
        .encode("utf-8")
    ).decode("utf-8")

I’ve deduced via the logging that the callback simply is not firing when inputs are modified. Here is an example of one of my inputs that is not triggering this callback:

dbc.RadioItems(options=['version', 'date'], value=state.get('x-axis-mode'), inline=True, id='x-axis-mode')

My first thought was that the example uses dcc, but I am using dbc, so I swapped this out for a dcc.RadioItems(), but still doesn’t trigger the callback.

I’ve also swapped the input in the callback to just look at a single id and confirmed it works in this case:

Input("x-axis-mode", "value")

To me it specifically looks like a problem with using the “all ids” method (which does not seem to be documented other than in this example as far as I can tell).

Has anyone else had this problem?

I’m running Dash: 3.0.4, Dcc 3.0.6, Python 3.12.10

Hi @robE127 and welcome to the Dash community :slight_smile:

The id of the inputs need to be a dictionary. You can find more information in the Pattern Matching callbacks section:

I don’t know how I missed this page in my searching :face_with_peeking_eye:

I see what you mean about having to change all my input ids to dictionaries. I missed that detail in the example I was following.

Thank you very much. :grin:

1 Like