I couldn’t find a workaround for this in the current version I tried using a dcc.Store as an intermediate but it still gets detected a cyclic dependency.
To test I even added raise dash.exceptions.PreventUpdate
to the beginning of my two callbacks but without sucess.
What I wanted to achieve sounded so simple a range slider with two input boxes left and right to give exact values if the slider is not accurate enough. I give up for now on this but this feature will be really really useful.
This was my try to adjust @Emil answer from 2014 ;).
@app.callback(
dash.dependencies.Output({'type': 'filter-min-sync', 'index': dash.dependencies.MATCH}, 'data'),
dash.dependencies.Output({'type': 'filter-max-sync', 'index': dash.dependencies.MATCH}, 'data'),
dash.dependencies.Input({'type': 'filter-bound-min', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.Input({'type': 'filter-bound-max', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.Input({'type': 'filter-range', 'index': dash.dependencies.MATCH}, 'value'),
)
def sync_filter_bounds(min_bound, max_bound, min_max_value):
if dash.callback_context.triggered[0]["prop_id"].contains("filter-bound"):
return min_bound, max_bound
elif dash.callback_context.triggered[0]["prop_id"].contains("filter-range"):
return min_max_value
return dash.no_update, dash.no_update
@app.callback(
dash.dependencies.Output({'type': 'filter-bound-min', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.Output({'type': 'filter-bound-max', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.Output({'type': 'filter-range', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.Input({'type': 'filter-min-sync', 'index': dash.dependencies.MATCH}, 'data'),
dash.dependencies.Input({'type': 'filter-max-sync', 'index': dash.dependencies.MATCH}, 'data'),
dash.dependencies.State({'type': 'filter-bound-min', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.State({'type': 'filter-bound-max', 'index': dash.dependencies.MATCH}, 'value'),
dash.dependencies.State({'type': 'filter-range', 'index': dash.dependencies.MATCH}, 'value'),
)
def update_components(current_min, current_max, bound_min_prev, bound_max_prev, range_prev):
min_value = current_min if current_min != bound_min_prev else dash.no_update
max_value = current_max if current_max != bound_max_prev else dash.no_update
current_range = [current_min, current_max]
range_value = current_range if current_range != range_prev else dash.no_update
return min_value, max_value, range_value