[BUG] Using pattern matching ALL for running argument fails when the list is empty
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
When using pattern matching for the running argument (ex: running=[(Output({'type': 'loading', 'id': ALL}, 'display'), 'show', 'hide')]), if there are no components on the page dash throws the error: state.paths.objs[idKey] is undefined
Describe your context
Please provide us your environment, so we can easily reproduce the issue.
- replace the result of
pip list | grep dashbelow
dash 3.0.4
Describe the bug
When using pattern matching for the running argument (ex: running=[(Output({'type': 'loading', 'id': ALL}, 'display'), 'show', 'hide')]), if there are no components on the page dash throws the error: state.paths.objs[idKey] is undefined
Expected behavior
No error, no side updates (since there are no components)
Minimum Working Example
import dash
from dash import Dash, html, dcc, callback, Output, Input, Patch, ALL, callback_context
import time
import random
app = Dash(use_pages=True, pages_folder="")
home_page_layout = html.Div([
dcc.Loading(
html.Div(id={'type':'scorecard', 'id': 'home1'}),
id={'type': 'loading', 'id': 'home1'}
),
dcc.Loading(
html.Div(id={'type':'scorecard', 'id': 'home2'}),
id={'type': 'loading', 'id': 'home2'}
)
])
other_page_layout = html.Div('Other')
dash.register_page('home', path='/', layout=home_page_layout)
dash.register_page('blank', path='/blank', layout=other_page_layout)
app.layout = html.Div([
dcc.Store(id='data'),
html.H1(children='Title of Dash App', style={'textAlign':'center'}),
html.Div([
html.Span([
dcc.Link(f"{page['name']} - {page['path']}", href=page["relative_path"]), ' | '
]) for page in dash.page_registry.values()
]),
html.Button('Reload Data', id='reload-data'),
dash.page_container
])
@callback(
Output('data', 'data'),
Input('reload-data', 'n_clicks'),
prevent_initial_call=True,
running=[(Output({'type': 'loading', 'id': ALL}, 'display'), 'show', 'hide')]
)
def get_data(n_clicks):
time.sleep(3)
return random.randint(0, 10)
@callback(
Output({'type': 'scorecard', 'id': 'home1'}, 'children'),
Input('data', 'data'),
prevent_initial_call=True
)
def scorecard1(data):
return f'Data: {data}'
@callback(
Output({'type': 'scorecard', 'id': 'home2'}, 'children'),
Input('data', 'data'),
prevent_initial_call=True
)
def scorecard2(data):
return f'Data squared: {data * data}'
if __name__ == '__main__':
app.run(debug=True)
In this example, pressing the "Reload Data" button on the second page (/blank) throws the error as the loading elements are all on the first page
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimum working example and reproduce the failure by opening /blank and pressing “Reload Data” while the matching loading components are on the home page. Done means the callback produces no error and makes no side updates when the pattern match finds no components.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100