Skip to content

Commit 06d9a4f

Browse files
committed
Fix multi set_props in background callbacks.
1 parent 6945807 commit 06d9a4f

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

dash/long_callback/_proxy_set_props.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ class ProxySetProps(dict):
77
def __init__(self, on_change):
88
super().__init__()
99
self.on_change = on_change
10+
self._data = {}
1011

1112
def __setitem__(self, key, value):
1213
self.on_change(key, value)
14+
self._data.setdefault(key, {})
15+
self._data[key] = {**self._data[key], **value}
16+
17+
def get(self, key):
18+
return self._data.get(key)

tests/integration/long_callback/app_arbitrary.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
Input("start", "n_clicks"),
2626
prevent_initial_call=True,
2727
background=True,
28+
interval=500,
2829
)
2930
def on_click(_):
3031
set_props("secondary", {"children": "first"})
32+
set_props("secondary", {"style": {"background": "red"}})
3133
time.sleep(2)
3234
set_props("secondary", {"children": "second"})
3335
return "completed"

tests/integration/long_callback/test_basic_long_callback017.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def test_lcbc017_long_callback_set_props(dash_duo, manager):
88
dash_duo.find_element("#start").click()
99

1010
dash_duo.wait_for_text_to_equal("#secondary", "first")
11+
dash_duo.wait_for_style_to_equal(
12+
"#secondary", "background-color", "rgba(255, 0, 0, 1)"
13+
)
1114
dash_duo.wait_for_text_to_equal("#output", "initial")
1215
dash_duo.wait_for_text_to_equal("#secondary", "second")
1316
dash_duo.wait_for_text_to_equal("#output", "completed")

0 commit comments

Comments
 (0)