-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Hi,
I observed that the target_components dictionary available in the dcc.Loading component does not work with components, which use the keyword argument allow_duplicate=True in their respective Output(...) definition.
Using debug=True in my example below indicates, that this stems from the fact, that allow_duplicate=True adds an @<HASH_VALUE> to the property name and hence the property referenced in the target_components dictionary cannot be found.
A pre-discussion of the issue can be found in the Plotly forum: https://community.plotly.com/t/using-dcc-loading-spinner-with-target-components-and-an-allow-duplicate-true-output/91998?u=robster
I have tested this behaviour with Dash 2.18.2 und Dash 3.0.3. Moreover for my example below I tested with dbc 1.7.1 and 2.0.2 respectively.
Best
Robert
--
from time import sleep
from dash import Dash, html, Input, Output
from dash.dcc import Loading
from dash_bootstrap_components import Input as dbcInput
app = Dash(__name__)
id_str = 'text-input'
app.layout = html.Div(children=html.Table(children=[
html.Tr(children=html.Td(children=Loading(
id='text-input-spinner',
debug=True,
target_components={id_str: 'value'},
type='default',
children=html.Div(children=dbcInput(
size='sm',
id=id_str,
type='text')
)))),
html.Tr(children=html.Td(html.Button(children='Click Me',
id='example-button'))),
html.Tr(children=html.Td(html.Label(children='Dummy',
id='le-label')))]))
@app.callback(output=[Output(id_str, 'value'),
Output('le-label', 'children')],
inputs=[Input('example-button', 'n_clicks')],
prevent_initial_call=True)
def update_output(_: int):
sleep(2)
return 'dummy_value', 'Check'
if __name__ == '__main__':
app.run(debug=True)