Open luewh opened 2 weeks ago
Related to this but not exactly the same. Can we consider the order of wildcards consistent between two inputs in the same callback or is that just regarded an implementation detail?
The below minimal example seems to work as expected right now since the order of the wildcard State
/Input
is the same so the id
is matched up correctly with each value
. This is something I'd really like to rely on but don't know whether it's guaranteed to remain the case.
Given that the above bug seems to have reappeared also, it would be great if it were possible to guarantee some ordering here so that we know whether the order is arbitrary or fixed 🙂
Also related issue but not quite the same: https://github.com/plotly/dash/issues/2834.
from dash import Dash, html, callback, Input, ALL, Output, State, dcc
@callback(Output("summary", "children"), State({"id": ALL}, "id"), Input({"id": ALL}, "value"))
def update_summary(ids, values):
summary = []
for id, value in zip(ids, values):
summary.append(html.P(f"Input {id['id']} has value {value}"))
return summary
app = Dash()
app.layout = [html.Div(id="summary")] + [dcc.Input(id={"id": i}, placeholder=f"Input {i}") for i in range(5)]
app.run()
dash==2.18.1 dash-core-components==2.0.0 dash-html-components==2.0.0 dash-bootstrap-components==1.6.0
Originally posted by @luewh in #2368