Skip to content

allow_duplicates to work with Loading #3289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#3284](https://github.com/plotly/dash/pull/3284) Fix component as props having the same key when used in the same container.
- [#3287](https://github.com/plotly/dash/pull/3287) Fix typing component generation & explicitize_args.
- [#3282](https://github.com/plotly/dash/pull/3282) Fix incorrect cancellation of pattern matched long callbacks.
- [#3289](https://github.com/plotly/dash/pull/3289) Fixed issue with debugTitle where status doesnt exist and allow_duplicates to ignore the hash for prop loading in the target.

## [3.0.3] - 2025-04-14

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CircleSpinner = ({
style,
}) => {
let debugTitle;
if (debug) {
if (debug && status) {
debugTitle = status.map((s) => <DebugTitle {...s} />);
}
let spinnerClass = fullscreen ? 'dash-spinner-container' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DebugTitle from './DebugTitle.jsx';

const CubeSpinner = ({status, color, fullscreen, debug, className, style}) => {
let debugTitle;
if (debug) {
if (debug && status) {
debugTitle = status.map((s) => <DebugTitle {...s} />);
}
let spinnerClass = fullscreen ? 'dash-spinner-container' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DefaultSpinner = ({
style,
}) => {
let debugTitle;
if (debug) {
if (debug && status) {
debugTitle = status.map((s) => <DebugTitle {...s} />);
}
let spinnerClass = fullscreen ? 'dash-spinner-container' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DebugTitle from './DebugTitle.jsx';
*/
const DotSpinner = ({status, color, fullscreen, debug, className, style}) => {
let debugTitle;
if (debug) {
if (debug && status) {
debugTitle = status.map((s) => <DebugTitle {...s} />);
}
let spinnerClass = fullscreen ? 'dash-spinner-container' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DebugTitle from './DebugTitle.jsx';

const GraphSpinner = ({status, fullscreen, debug, className, style}) => {
let debugTitle;
if (debug) {
if (debug && status) {
debugTitle = status.map((s) => <DebugTitle {...s} />);
}
let spinnerClass = fullscreen ? 'dash-spinner-container' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,69 @@ def updateDiv(n_clicks):
dash_dcc.wait_for_text_to_equal("#div-1", "changed")

assert dash_dcc.get_logs() == []


# multiple components, only one triggers the spinner
def test_ldcp017_loading_component_target_components_duplicates(dash_dcc):

lock = Lock()

app = Dash(__name__)

app.layout = html.Div(
[
dcc.Loading(
[
html.Button(id="btn-1"),
html.Button(id="btn-2", children="content 2"),
],
className="loading-1",
target_components={"btn-2": "children"},
debug=True,
)
],
id="root",
)

@app.callback(Output("btn-1", "children"), [Input("btn-2", "n_clicks")])
def updateDiv1(n_clicks):
if n_clicks:
with lock:
return "changed 1"

return "content 1"

@app.callback(
Output("btn-2", "children", allow_duplicate=True),
[Input("btn-1", "n_clicks")],
prevent_initial_call=True,
)
def updateDiv2(n_clicks):
if n_clicks:
with lock:
return "changed 2"

return "content 2"

dash_dcc.start_server(app)

dash_dcc.wait_for_text_to_equal("#btn-1", "content 1")
dash_dcc.wait_for_text_to_equal("#btn-2", "content 2")

with lock:
dash_dcc.find_element("#btn-1").click()

dash_dcc.find_element(".loading-1 .dash-spinner")
dash_dcc.wait_for_text_to_equal("#btn-2", "")

dash_dcc.wait_for_text_to_equal("#btn-2", "changed 2")

with lock:
dash_dcc.find_element("#btn-2").click()
spinners = dash_dcc.find_elements(".loading-1 .dash-spinner")
dash_dcc.wait_for_text_to_equal("#btn-1", "")

dash_dcc.wait_for_text_to_equal("#btn-1", "changed 1")
assert spinners == []

assert dash_dcc.get_logs() == []
2 changes: 1 addition & 1 deletion dash/dash-renderer/src/actions/callbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ export function executeCallback(
const __execute = async (): Promise<CallbackResult> => {
const loadingOutputs = outputs.map(out => ({
path: getPath(paths, out.id),
property: out.property,
property: out.property?.split('@')[0],
id: out.id
}));
dispatch(loading(loadingOutputs));
Expand Down