Skip to content
Open
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 @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#4218](https://github.com/plotly/dash/pull/4218) Fix `pages_folder` written with `/` on Windows, such as `"src/pages"`, giving wrong page module names and paths. Fixes [#4217](https://github.com/plotly/dash/issues/4217).
- [#4220](https://github.com/plotly/dash/pull/4220) Fix the `DASH_VALIDATE_CALLBACKS` environment variable being ignored, although `Dash.run` and `Dash.enable_dev_tools` document it for `dev_tools_validate_callbacks`. Fixes [#4219](https://github.com/plotly/dash/issues/4219).
- [#4235](https://github.com/plotly/dash/pull/4235) Fix FastAPI deep links for mounted Dash apps and disabled or repeated lifespans. Apps sharing a server respect their URL prefixes, and explicit routes take precedence even when added after startup. Fixes [#4234](https://github.com/plotly/dash/issues/4234).
- [#4240](https://github.com/plotly/dash/pull/4240) Fix `flatten_grouping` treating dict and list subclasses such as `OrderedDict` as a single value, which broke callbacks whose output or inputs are an `OrderedDict`, a regression from #3303.

## [4.5.2] - 2026-11-27

Expand Down
6 changes: 2 additions & 4 deletions dash/_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ def flatten_grouping(grouping, schema=None):
push((grouping, schema))
while stack:
group, sch = pop()
# Inline isinstance checks for perf
typ = type(sch)
if typ is tuple or typ is list:
if isinstance(sch, (tuple, list)):
# Avoid double recursion / excessive list construction
for ge, se in zip(group, sch):
push((ge, se))
elif typ is dict:
elif isinstance(sch, dict):
for k in sch:
push((group[k], sch[k]))
else:
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/library/test_grouped_callbacks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import OrderedDict

import dash
from dash._grouping import make_grouping_by_index, grouping_len, flatten_grouping
from dash._utils import create_callback_id
Expand Down Expand Up @@ -90,6 +92,41 @@ def test_callback_output_size(mixed_grouping_size):
check_output_for_grouping(mixed_grouping_size[0])


def test_callback_output_and_input_dict_subclass():
app = dash.Dash()

@app.callback(
output=OrderedDict(
[("x", Output("out-x", "children")), ("y", Output("out-y", "children"))]
),
inputs=OrderedDict(
[("a", Input("in-a", "value")), ("b", Input("in-b", "value"))]
),
)
def fn(a, b):
return {"x": a, "y": b}

callback_id = create_callback_id(
[Output("out-x", "children"), Output("out-y", "children")], []
)
wrapped_fn = app.callback_map[callback_id]["callback"]
result = json.loads(
wrapped_fn(
1,
2,
outputs_list=[
{"id": "out-x", "property": "children"},
{"id": "out-y", "property": "children"},
],
)
)

assert result["response"] == {
"out-x": {"children": 1},
"out-y": {"children": 2},
}


def check_callback_inputs_for_grouping(grouping):
"""
Check the expected behavior of a callback function configured to input arguments
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/library/test_grouping.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import OrderedDict

from dash.dependencies import Input
from dash._grouping import (
flatten_grouping,
Expand Down Expand Up @@ -74,6 +76,17 @@ def test_flatten_odd_value():
assert len(result) == grouping_len(vals_collection)


def test_flatten_dict_subclass():
grouping = OrderedDict([("a", 0), ("b", (1, 2))])
result = flatten_grouping(grouping)
assert result == [0, 1, 2]
assert len(result) == grouping_len(grouping)
assert make_grouping_by_index(grouping, ["x", "y", "z"]) == {
"a": "x",
"b": ["y", "z"],
}


# Test make_grouping_by_position
def make_flat_values(size):
return list(string.ascii_lowercase[:size])
Expand Down